Skip to content

Instantly share code, notes, and snippets.

View tancnle's full-sized avatar
🌸
Living The Dream ᕙ༼*◕_◕*༽ᕤ

Tan Le tancnle

🌸
Living The Dream ᕙ༼*◕_◕*༽ᕤ
View GitHub Profile
@tonyc
tonyc / gist:1384523
Last active June 3, 2024 15:34
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@epegzz
epegzz / Monaco_Linux-Powerline.ttf
Created January 18, 2012 17:19
Monaco for vim-powerline
@rakhmad
rakhmad / clojure.md
Created April 17, 2012 15:55
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@nono
nono / blowfish.rb
Created June 26, 2012 10:57
How to encrypt and decrypt Blowfish in Ruby 1.9 with https://github.com/drench/blowfish.js
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0
@mikehaertl
mikehaertl / gist:3258427
Created August 4, 2012 15:40
Learn you a Haskell - In a nutshell

Learn you a Haskell - In a nutshell

This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.


1. Introduction

  • Haskell is a functional programming language.
@mikelikesbikes
mikelikesbikes / dynamic.clj
Created October 17, 2012 18:32 — forked from bjeanes/dynamic.clj
Change Maker in clojure
(ns katas.change-maker)
(defn num-pairs
"Returns all combinations of [x y] and (<= x y) where (= cents (+ x y))"
[cents]
(for [x (reverse (range 1 (inc (quot cents 2)))) ;; use the range from midpoint to 1 so that we walk the
;; shortest side of the tree first
:let [y (- cents x)]]
[x y]))
@gr4y
gr4y / gist:5517010
Created May 4, 2013 09:53
How I setup my ruby environment:
#
# This is the way I configured my ruby environment on ArchLinux.
#
# I don't like the overhead of rvm, so I use chruby to switch between ruby versions.
# So first you need to install chruby from source:
#
# https://github.com/postmodern/chruby#install
#
# To build ruby from source I use ruby-build, so after chruby we install ruby-build:
#
@johnmyleswhite
johnmyleswhite / JuliaGlobals
Last active August 10, 2018 10:58
Naively counting Pythagorean triples in Python and Julia
total = 0
N = 300
start_time = time()
for a in 0:(N - 1)
for b in 0:(N - 1)
for c in 0:(N - 1)
if a^2 + b^2 == c^2
total = total + 1
@neilj
neilj / renderHTML.js
Created October 18, 2013 05:26
Rendering HTML with styles in a way that doesn't conflict with other styles on the page, without using an iframe for each HTML fragment.
var styleFrame = document.createElement( 'iframe' ),
stylesWaiting = [],
styleFrameIsReady = false;
styleFrame.setAttribute( 'style',
'visibility:hidden;position:absolute;top:0;left:0;width:1px;height:1px;' );
styleFrame.addEventListener( 'load', function () {
var doc = styleFrame.contentDocument,
html, i, l;
@icyleaf
icyleaf / ar_migrate.rb
Last active June 6, 2024 20:06
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default