Skip to content

Instantly share code, notes, and snippets.

View jasl's full-sized avatar
😂
~

Jun Jiang jasl

😂
~
View GitHub Profile
@jasl
jasl / wawammseg.py
Created June 30, 2012 11:41 — forked from onlytiancai/wawammseg.py
写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码
# -*- coding:utf-8 -*-
'写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码'
'搜狗词库下载地址:http://vdisk.weibo.com/s/7RlE5'
import string
__dict = {}
def load_dict(dict_file='words.dic'):
'加载词库,把词库加载成一个key为首字符,value为相关词的列表的字典'
@jasl
jasl / 01. Gemfile
Created August 27, 2012 18:39 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
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 / List.cs
Created November 2, 2012 10:57 — forked from JeffreyZhao/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 / parse_pcap.rb
Created November 29, 2012 06:03
Parse Pcap file
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"
@jasl
jasl / 3gates.rb
Created May 23, 2013 18:46
three gates
require 'securerandom'
def seed
SecureRandom.uuid.gsub(/[-a-z]/,"").to_i
end
total = 10000
rights = 0
(1..total).each do
@jasl
jasl / fix_zlib_incorrect_header_check.rb
Created July 6, 2013 10:04
A monkey patch to fix a issue on decompress response. A typical scenario is omnioauth do oauth through proxy.
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,
<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 / CircleImageTransformation.java
Created July 25, 2016 11:48 — 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!
/**
* 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";
@jasl
jasl / webpacker.rake
Created October 6, 2018 20:01
Capistrano recipe for Webpacker without Assets pipeline, put it into lib/capistrano/tasks/webpacker.rake and require it in Capfile
# 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"

Linking my account jasl on GitHub with my address 5EeRXiJHFLKCCu1CPKUKELfumNaKL2cCNweAvqE1wMwyhdUx on Substrate in prod.mycryptoprofile.io, and the challenge code is: c66426db5413b0c72ff352d0cf9ace04. #LitentryVerifyMyAddress