Skip to content

Instantly share code, notes, and snippets.

Avatar
😂
~

Jun Jiang jasl

😂
~
View GitHub Profile
@jasl
jasl / webpacker.rake
Created Oct 6, 2018
Capistrano recipe for Webpacker without Assets pipeline, put it into lib/capistrano/tasks/webpacker.rake and require it in Capfile
View webpacker.rake
# frozen_string_literal: true
namespace :webpacker do
desc "Compile webpacker assets"
task :compile do
on release_roles(fetch(:assets_roles)) do
within release_path do
with rails_env: fetch(:rails_env), rails_groups: fetch(:rails_assets_groups) do
execute :rake, "yarn:install"
execute :rake, "webpacker:compile"
@jasl
jasl / CircleImageTransformation.java
Created Jul 25, 2016 — forked from codezjx/CircleImageTransformation.java
A picasso circle image transformation. Optimized version of: https://gist.github.com/julianshen/5829333. Use shader.setLocalMatrix() method to draw circle bitmap not from source bitmap left-top. So, we no need to create square bitmap!
View CircleImageTransformation.java
/**
* Created by codezjx on 2016/5/4.
*/
public class CircleImageTransformation implements Transformation {
/**
* A unique key for the transformation, used for caching purposes.
*/
private static final String KEY = "circleImageTransformation";
View 1.php
<script>
// function doNothing(e){
// e = e || window.event; //window.event, IE的写法
// if(e.stopPropagation){
// e.stopPropagation();
// e.preventDefault();
// }else{ //IE
// e.cancelBubble = true;
// e.returnValue = false;
// };
@jasl
jasl / fix_zlib_incorrect_header_check.rb
Created Jul 6, 2013
A monkey patch to fix a issue on decompress response. A typical scenario is omnioauth do oauth through proxy.
View fix_zlib_incorrect_header_check.rb
class Net::HTTPResponse
class Inflater
##
# Finishes the inflate stream.
def finish
begin
@inflate.finish
rescue Zlib::DataError
# No luck with Zlib decompression. Let's try with raw deflate,
@jasl
jasl / 3gates.rb
Created May 23, 2013
three gates
View 3gates.rb
require 'securerandom'
def seed
SecureRandom.uuid.gsub(/[-a-z]/,"").to_i
end
total = 10000
rights = 0
(1..total).each do
@jasl
jasl / parse_pcap.rb
Created Nov 29, 2012
Parse Pcap file
View parse_pcap.rb
require 'ipaddr'
def decode(p, m = "i*")
p.unpack(m)[0]
end
def parse_ip_p(data)
r = {}
if data[12..13] == "\x08\x00" and data[14] == "\x45" and data[23] == "\x11"
puts "find a IPV4 UDP package"
View List.cs
// As we all know, the generic List<T> class in .NET doesn't
// have a RemoveMultiple method. Could you implement it for me?
// Say the elements are kept in the _items field, which is an
// array of type T. Also, use _count to keep the current number
// of elements.
// PS: You can compare two items with "==" operator.
namespace System.Collections.Generic
{
public class List<T>
@jasl
jasl / 01. Gemfile
Created Aug 27, 2012 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
View 01. Gemfile
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@jasl
jasl / wawammseg.py
Created Jun 30, 2012 — forked from onlytiancai/wawammseg.py
写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码
View wawammseg.py
# -*- coding:utf-8 -*-
'写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码'
'搜狗词库下载地址:http://vdisk.weibo.com/s/7RlE5'
import string
__dict = {}
def load_dict(dict_file='words.dic'):
'加载词库,把词库加载成一个key为首字符,value为相关词的列表的字典'