Skip to content

Instantly share code, notes, and snippets.

View dreamingblackcat's full-sized avatar

Chan Myae San Hlaing dreamingblackcat

View GitHub Profile
@dreamingblackcat
dreamingblackcat / file_organizer.rb
Last active August 29, 2015 14:09
This is a simple ruby script for organizing my pdf files within a folder(I used Ubuntu but any linux distro should work).
#What I pre-assumed are as follow:
# The directory you want to clean up should have multiple folders and files( in my case pdf files and category folders)
# The script job is to interactively help you in the process of moving files into your desired folder
# =========USAGE========
# 1. run the script inside the director you want to organize
# it will prompt you for each file
# 2. type a folder name you want the file to be moved and hit ENTER.
# if there is a folder with the name just exactly as you typed, it will move the file into it
# else it will show you a list of folder names that match what you typed
# if the matched folder is only one, then you can hit enter without typing any words to use the folder as the desired folder
@dreamingblackcat
dreamingblackcat / two_power_eight_quiz.ex
Last active August 29, 2015 14:11
An elixir module for defining power function without using multiplication operator.
defmodule Compute do
def twoPlus(num), do: 2+num
def twoTimes(0), do: 0
def twoTimes(num) when num < 0, do: -twoTimes(-num)
def twoTimes(num) when num > 0, do: twoPlus(twoTimes(num-1))
@dreamingblackcat
dreamingblackcat / devise.my.yml
Created January 13, 2015 12:05
Translation for devise gem
mm:
errors:
messages:
expired: "မှာ သက်တန်းလွန်သွားပါပြီ။ကျေးဇူးပြုပြီး အသစ်ထပ်မံတောင်းဆိုပါ။"
not_found: "ရှာမ တွေ့ပါ။"
already_confirmed: "မှာ အတည်ပြုပြီးဖြစ်ပါသည်။ ကျေးဇူးပြု၍အ ကောင့်ကို၀င်ကြည့်ပါ။"
not_locked: "ကို ပိတ်ပင်ထားခြင်းမရှိပါ။"
not_saved:
one: "ဤ %{resource} အားသိမ်းဆည်းနိုင်ရန် error 1 ခုအားဖြေရှင်းဖို့လိုပါသည်။:"
other: "ဤ %{resource} အားသိမ်းဆည်းနိုင်ရန် error %{count} ခုအားဖြေရှင်းဖို့လိုပါသည်။"
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@dreamingblackcat
dreamingblackcat / matrix
Last active March 8, 2018 09:15
A simple ruby script for displaying fancy terminal screen
#!/usr/local/bin/ruby
# matrix test with ruby
# Used Two Gems 'curses' for terminal cursor moving and 'rainbow' for coloring
# first run "gem install curses rainbow"
# then run this file
# Note: you can tweak parameters when initializing the object
# Enjoy :)
require "curses"
require 'rainbow/ext/string'
http://torrentz.eu/2f204717dfb19a95a21482d1cb313c7c68e55972
http://torrentz.eu/f2d2b18df7863577d3347412bace7673a4ef152a
http://torrentz.eu/c9e0f85fdab2e2f5e521b2190695a0202152f56c
http://torrentz.eu/0b1a4f39446a9472e20ec7b567b392bf35cc3c66
http://torrentz.eu/82b6219555c4e73ecd812c5c2df46b78d0339cf9
source 'https://rubygems.org'
# default gems here
#---------------------------
# add paperclip and bootstrap
gem "paperclip", "~> 4.1"
gem 'bootstrap-sass', '~> 3.1.1'

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
/**
* Module dependencies.
*/
var express = require('express');
var vhost = require('vhost');
/*
edit /etc/hosts:
@dreamingblackcat
dreamingblackcat / README.md
Last active September 16, 2015 14:11 — forked from mbostock/.block
Hexagon Mesh

Click and drag above to paint red hexagons. A black outline will appear around contiguous clusters of red hexagons. This outline is constructed using topojson.mesh, part of the TopoJSON client API. A filter is specified so that the mesh only contains boundaries that separate filled hexagons from empty hexagons.

The hexagon grid itself is represented as TopoJSON, but is constructed on-the-fly in the browser. Since TopoJSON requires quantized coordinates, the hexagon grid is represented as integers, with each hexagon of dimensions 3×2. Then a custom projection is used to transform these irregular integer hexagons to normal hexagons of the desired size.