Skip to content

Instantly share code, notes, and snippets.


Jun Jiang jasl

View GitHub Profile
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 /
Created Jul 25, 2016 — forked from codezjx/
A picasso circle image transformation. Optimized version of: Use shader.setLocalMatrix() method to draw circle bitmap not from source bitmap left-top. So, we no need to create square bitmap!
* 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
// 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 / 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
rescue Zlib::DataError
# No luck with Zlib decompression. Let's try with raw deflate,
jasl / 3gates.rb
Created May 23, 2013
three gates
View 3gates.rb
require 'securerandom'
def seed
total = 10000
rights = 0
( do
jasl / parse_pcap.rb
Created Nov 29, 2012
Parse Pcap file
View parse_pcap.rb
require 'ipaddr'
def decode(p, m = "i*")
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 / 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'
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
jasl /
Created Jun 30, 2012 — forked from onlytiancai/
# -*- coding:utf-8 -*-
import string
__dict = {}
def load_dict(dict_file='words.dic'):