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
@tancnle
tancnle / kanjis.rb
Created August 31, 2019 09:44
Common Kanjis
["一","二","三","四","五","六","七","八","九","十","口","日","月","田","目","古","吾","冒","朋","明","唱","晶","品","呂","昌","早","旭","世","胃","旦","胆","亘","凹","凸","旧","自","白","百","中","千","舌","升","昇","丸","寸","肘","専","博","占","上","下","卓","朝","嘲","只","貝","唄","貞","員","貼","見","児","元","頁","頑","凡","負","万","句","肌","旬","勺","的","首","乙","乱","直","具","真","工","左","右","有","賄","貢","項","刀","刃","切","召","昭","則","副","別","丁","町","可","頂","子","孔","了","女","好","如","母","貫","兄","呪","克","小","少","大","多","夕","汐","外","名","石","肖","硝","砕","砂","妬","削","光","太","器","臭","嗅","妙","省","厚","奇","川","州","順","水","氷","永","泉","腺","原","願","泳","沼","沖","汎","江","汰","汁","沙","潮","源","活","消","況","河","泊","湖","測","土","吐","圧","埼","垣","填","圭","封","涯","寺","時","均","火","炎","煩","淡","灯","畑","災","灰","点","照","魚","漁","里","黒","墨","鯉","量","厘","埋","同","洞","胴","向","尚","字","守","完","宣","宵","安","宴","寄","富","貯","木","林","森","桂","柏","枠","梢","棚","杏","桐","植","椅","枯","朴","村","相","机","本","札","暦","案","燥","未","末","昧","沫","味","妹","朱","株","若","草","苦","苛","寛","薄","葉","模","漠","墓","暮","膜","苗","兆","桃","眺","犬","状","黙","然"
@tancnle
tancnle / sha1_vs_md5.py
Created August 3, 2017 23:34
SHA1 vs MD5 bechmark
import hashlib
import pytest
foo = b'The lazy fox jumps over the running dogs'
def test_sha1(benchmark):
sha1 = hashlib.sha1()
sha1.update(foo)
benchmark(sha1.hexdigest)
@tancnle
tancnle / keybase.md
Created May 28, 2016 02:17
keybase.md

Keybase proof

I hereby claim:

  • I am tancnle on github.
  • I am tancnle (https://keybase.io/tancnle) on keybase.
  • I have a public key ASAFe59Qml_JGnLjL3_p0zbaOmzLmD6LQN4SewnswfG4Ago

To claim this, I am signing this object:

@tancnle
tancnle / countCSSRules.js
Created January 12, 2016 06:34 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@tancnle
tancnle / html5_speech.js
Last active August 29, 2015 14:24
Make your browser speak
var say = function(msg) {
var speech = new SpeechSynthesisUtterance();
var voices = window.speechSynthesis.getVoices();
speech.voice = voices[10]; // 'en-AU' 'Karen'
speech.text = msg;
speech.onend = function(e) {
console.log('Finished in ' + event.elapsedTime + ' seconds.');
};
@tancnle
tancnle / kindergarten_garden.rb
Created July 2, 2015 04:12
Allocate plans to students
require 'matrix'
cups_per_student_per_row = 2
plants = %w( G C R V )
students = %w( Alice Bob Charlie David Eve Fred Ginny Harriet Ileana Joseph Kincaid Larry ).sort
layout = Matrix[
24.times.map{ plants.sample },
24.times.map{ plants.sample }
]
@tancnle
tancnle / saddle_points.rb
Created July 2, 2015 04:09
Find saddle points from given matrix
require 'matrix'
matrix = Matrix[
[9, 2, 8, 6],
[5, 3, 1, 5],
[6, 8, 7, 9]
]
cols = matrix.column_vectors
rows = matrix.row_vectors
@tancnle
tancnle / roman_numerals.rb
Last active August 29, 2015 14:22
Convert arabic to roman numerals
def possible_reps(input)
lambda {|k,_| k <= input}
end
def build_roman(input)
lambda do |result, (arabic, roman)|
if (input >= arabic)
quotient, input = input.divmod(arabic)
result << roman*quotient
end
@tancnle
tancnle / ForExpressionExplain.scala
Created March 24, 2015 00:33
Scala For Expressions
case class Mascot(name: String)
case class SportTeam(mascot: Mascot)
case class City(sportTeams: List[SportTeam])
case class State(cities: List[City])
case class Country(states: List[State])
def getAllMascots(country: Country): List[Mascot] = {
for {
states <- country.states
cities <- states.cities
@tancnle
tancnle / index.html
Created October 14, 2014 10:35
Angular controller calling multiple services (http://jsbin.com/zuvuwabolovu/7)
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app='testScope'>
<div ng-controller='BankController'>
<div transaction>