Skip to content

Instantly share code, notes, and snippets.

@karloku
karloku / mods.md
Created December 16, 2019 16:43
CSL Mods
@karloku
karloku / check_brackets.java
Last active September 26, 2016 07:03
括号匹配 Java Sample
import java.util.*;
public class Main{
public static boolean checkLegal(String A) {
Stack<Character> s = new Stack<>();
HashMap<Character,Character> map = new HashMap<Character,Character>();
map.put('[',']');
map.put('{','}');
map.put('(',')');
for (char c : A.toCharArray()) {
@karloku
karloku / file0.txt
Created March 30, 2016 11:54
Using ES6 style {a, b, c} hash construct in Ruby ref: http://qiita.com/karloku/items/0a3c8ed3e39518de5b90
var year = 2016;
var month = 3;
var day = 30;
var theDate = { year, month, day };
@karloku
karloku / README.md
Last active March 30, 2018 07:28
Rails Template using GraphQL

This template is supposed to be applied to rails 5.

run with:

rails new <application_name> --template=https://gist.githubusercontent.com/karloku/edd6a158e275fdefa334/raw/b56175bee5b45d32310aeb620e23be44e3c2a56d/graphql_template.rb -T

using gems:

  • graphql
  • graphql-mutable_type
@karloku
karloku / .rubocop.yml
Created February 25, 2016 06:56
My Rails .rubocop.yml
# This is the configuration used to check the rubocop source code.
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
- 'lib/templates/**/*'
- 'config/deploy.rb'
- 'config/deploy/*.rb'
@karloku
karloku / phantomjs_mp.html
Created September 6, 2015 04:39
Nokogiri failed to parse this document
<!DOCTYPE html><html><head>
<script type="text/javascript">
var sampling = Math.random() < 0.001;
var page_begintime = (+new Date());
(sampling) && ((new Image()).src = "http://isdspeed.qq.com/cgi-bin/r.cgi?flag1=7839&flag2=7&flag3=8&15=1000&r=" + Math.random());
var biz = "MzAwOTEwMDYyMw==";
var sn = "665480f07764cc3ac964168a29b5a070" || "";
var mid = "209864846" || "";
@karloku
karloku / sorcery_adapter.rb
Last active August 29, 2015 14:17
Using Sorcery's basic authorization in Grape
module API
module SorceryAdapter
AUTHENTICITY_TOKEN_LENGTH = 32
def self.included(mod)
mod.instance_eval {
helpers do
### Adapt for Sorcery (some directly taken from rails codes)