Skip to content

Instantly share code, notes, and snippets.

var result = ~ function(str) {
// Define a DSL
var r = function(target, replace) {
str = str.replace(new RegExp(target, 'gi'), replace || target);
};
// Use the DSL
r('JavaScript');
r('gogle', 'Google');
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
bigf = (n) ->
for i in [2..Math.sqrt n]
return n / i unless n % i
n
LPF = (n) ->
bf = bigf n
return bf if bf == n
LPF bf
@rixtox
rixtox / README.md
Last active August 29, 2015 13:57
JavaScript Asynchronous Deep Mapping With Promise

deepMap(object, iterator [, routePrefix])

Iterate and map recursively into an object. Return a promise object with a standard then interface created by Q. The depth and data types can be controlled by the iterator.

When encounters an array object, the returned value is an object use the indices of the array as its keys in String.

Note, that module q is required to handle the async quenue and create promises.

Arguments

var fs = require('fs')
var Q = require('q')
var fs_stat = Q.denodeify(fs.stat)
var fs_readdir = Q.denodeify(fs.readdir)
var files = [
'./fixtures/file1',
'./fixtures/file2',
'./fixtures/file3',
'./fixtures/file4'
var data = {
stat: {
mastery: {
zh: '精通',
detail: '影响角色不同天赋的不同技能效果'
},
stamina: {
zh: '耐力',
detail: '影响角色和宠物的生命值'
},
@rixtox
rixtox / .zshrc
Last active October 23, 2017 07:22
My .zshrc
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="xir"
plugins=(git extract zsh-syntax-highlighting zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
alias ls='ls --color'
alias lsa='ls -lah'
@rixtox
rixtox / Generate Iconset.jsf
Created July 12, 2013 16:15
You need to add executable privileges for icns.sh after the first time you run the command. If you changed your project name, you need to remove icns.sh and rerun the command.
/***********************************
Adobe Fireworks Command File
Auto export iconset with different
resolutions for icns generating.
Install into ~/Library/Application
Support/Adobe/Fireworks CS6/Commands
************************************
@rixtox
rixtox / jsnoquot.html
Last active December 15, 2015 19:09
Encode your JavaScript without any quotation mark.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS NoQuot</title>
<style>
textarea {
font-family: 'consolas';
}
</style>
@rixtox
rixtox / tetwist_marathon.js
Created March 16, 2013 17:02
A initial plan for how the engine should be formed.
var marathon_playfield = new voka.playfield({
width: 10,
height: 20,
event_handlers: {
lines_cleared: function(event) {
var current_level = event.game.level,
lines_cleared = event.lines_cleared.length;
var addition = {
1: current_level * 100,