Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
@qzchenwl
qzchenwl / Test.java
Created August 14, 2013 03:06
Stream implemented in java
package util;
import org.springframework.util.Assert;
import java.math.BigDecimal;
import java.util.Iterator;
public class Test {
public static void main(String[] args) {
import Data.List
floors = 0 : 1 : map step [2..]
where step h = minimum [ 1 + max (x-1) (floors!!(h-x)) | x <- [1..h-1] ]
main = print $ take 200 floors
<?php
$param1 = "哈哈1\t𤭢2\\3\"";
$param2 = "10";
$param11 = "哈\xd5\"哈1\t𤭢2\\3\"";
$param22 = "10 union 1,2";
$sql1 = "select * from user where username=" . literal($param1) . " and age=" . literal(intval($param2));
$sql2 = "select * from user where username=" . literal($param1) . " and age=" . literal($param2);
$sql3 = "select * from user where username=" . literal($param11) . " and age=" . literal(intval($param2));
@qzchenwl
qzchenwl / pingpong-0.hs
Last active December 15, 2015 10:18
Glimpse of Cloud Haskell http://www.well-typed.com/blog/68
{-# LANGUAGE DeriveDataTypeable #-}
module Main where
import Control.Concurrent ( threadDelay )
import Data.Binary
import Data.Typeable
import Control.Distributed.Process
import Control.Distributed.Process.Node
// ==UserScript==
// @name Duomi Download
// @namespace http://diveintogreasemonkey.org/download/
// @description Easy to download duomi music
// @include http://huodong.duomi.com/*
// ==/UserScript==
var unsafeWindow = (function () {
var dummyElem = document.createElement('p');
dummyElem.setAttribute('onclick', 'return window;');
@qzchenwl
qzchenwl / LLRBTree.hs
Last active December 11, 2015 05:39
Implemention of Left Leaning Red Black Tree, see http://www.cs.princeton.edu/~rs/talks/LLRB/RedBlack.pdf
{-# LANGUAGE BangPatterns #-}
module LLRBTree where
import Data.List (foldl', nub, (\\))
import qualified Data.List as L
import Data.Maybe
import System.Cmd
import Prelude hiding (minimum)
import Debug.Trace
import Test.QuickCheck
module Main where
import Data.Char (digitToInt)
sort :: (Ord a) => [a] -> [a]
sort [] = []
sort (x:xs) = sort smaller ++ [x] ++ sort greater
where
smaller = filter (not.(> x)) xs
greater = filter (> x) xs
@qzchenwl
qzchenwl / Church.hs
Created April 18, 2012 14:10
Church Number
module Church where
import Prelude ((.), ($), id, fst, undefined, length)
zero f = id
inc n f = f . n f
one f = f
two f = f . f
three f = f . f . f
@qzchenwl
qzchenwl / Indexable.hs
Created April 12, 2012 03:05
type class Indexable
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Indexable where
import qualified Data.Aeson as A
import qualified Data.HashMap.Strict as HM
import qualified Data.Map as M
import qualified Data.Vector as V
import Data.Text (Text, unpack)