Skip to content

Instantly share code, notes, and snippets.

@sudodo
sudodo / remove_symbol.rb
Last active August 29, 2015 14:04
Remove symbol
# encoding: utf-8
def remove_symbol str
wide_symbol = "、 。 , . ・ : ; ? ! ゛ ゜ ´ ` ¨ ^  ̄ _ ヽ ヾ ゝ ゞ 〃 仝 々 〆 〇 ー ― ‐ / \ ~ ∥ | … ‥ ‘ ’ “ ” ( ) 〔 〕 [ ] { } 〈 〉 《 》 「 」 『 』 【 】 + - ± × ÷ = ≠ < > ≦ ≧ ∞ ∴ ♂ ♀ ° ′ ″ ℃ ¥ $ ¢ £ % # & * @ § ☆ ★ ○ ● ◎ ◇ ◆ □ ■ △ ▲ ▽ ▼ ※ 〒 → ← ↑ ↓ 〓"
str.gsub!(/[!-\/:-@\[-`{-~]*/,"") # => remove word consisting of only numeric or special chars like 123, `"$#
str.gsub!(/[#{wide_symbol}]/,"")
# str.gsub!(/[!。、*・]/,"")
str.gsub!(/\p{Symbol}/,"")
str
end
@sudodo
sudodo / add_line.sh
Created March 10, 2015 00:52
Add a line at the begging of large file
#! /bin/bash
echo "index,datetime,count" > newfile.csv
cat original_file.csv >> newfile.csv
@sudodo
sudodo / not_list_comprehension_with_multithreading.py
Created March 11, 2015 03:00
Python 2.x (not) list comprehension with multithreading
import multiprocessing
import itertools
def get_trajectory(arg1, arg1):
return [999,888,777,666]
def get_traj_as_star(arg):
return get_trajectory(arg[1], arg[2])
def run_multi_particle(num_particle, num_time, num_mesh, multi_thread=True):
@sudodo
sudodo / server.js
Created October 23, 2011 05:10 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@sudodo
sudodo / .gitignore
Created October 23, 2011 05:13
sina weibo OAuth with node-oauth for node.js+express
node_modules
config.js
@sudodo
sudodo / server.js
Created October 23, 2011 05:24 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@sudodo
sudodo / General Rails.logger
Created October 28, 2011 06:40
logger outside ActiveRecord, ActiveController, ActionView
Rails.logger.info "Some debugging info I want to see in my development log."
@sudodo
sudodo / commit_explicitly_in_rails
Created December 1, 2011 05:54
How to commit explicitly in Rails.
ActiveRecord::Base::connection::execute("COMMIT")
@sudodo
sudodo / JS_module_pattern_constructor
Created January 21, 2012 06:22
JavaScript constructor module pattern skelton
MYAPP.namespace('MYAPP.utilities.Array');
MYAPP.utilities.Array = (function () {
// dependencies
var uobj = MYAPP.utilities.object,
ulang = MYAPP.utilities.lang;
// private properties and methods...
var Constr;
@sudodo
sudodo / JavaScript module pattern skelton
Created January 21, 2012 06:26
JavaScript module pattern skelton
MYAPP.namespace('MYAPP.utilities.array');
MYAPP.utilities.array = (function () {
// dependencies
var uobj = MYAPP.utilities.object,
ulang = MYAPP.utilities.lang,
// private properties
array_string = "[object Array]", ops = Object.prototype.toString;