Skip to content

Instantly share code, notes, and snippets.

View zosiu's full-sized avatar

Zsófia Balogh zosiu

  • 11:58 (UTC +02:00)
View GitHub Profile
@zosiu
zosiu / tatoeba.rb
Last active August 29, 2015 14:20
Analyzed random japanese senctence from tatoeba.org
require 'mechanize'
require 'kuromoji'
dom = Mechanize.new.get("http://tatoeba.org/eng/sentences/show/jpn")
jp_sentence = dom.parser.at("//div[@lang = 'ja']").text
# => "万一に備えて傘を持っていった方がいいだろうな。"
jp_sentence_w_furigana = dom.parser.at("//div[@lang = 'ja-Latn']").text
# => "万一[まんいち] に[] 備え[そなえ] て[] 傘[かさ] を[] 持っ[もっ] て[] いっ[] た[] 方[ほう] が[] いい[] だろ[] う[] な[] 。[]"
en_sentence = dom.parser.at("//div[@lang = 'en']").text
# => "Perhaps I should take an umbrella with me just in case."
@zosiu
zosiu / Instagram_real_time_updates_controller.rb
Created May 19, 2015 14:43
Instagram Real Time Update w/ Rails
class InstagramRealTimeUpdatesController < ActionController::Base
def callback
case request.method_symbol
when :get
render text: Instagram.meet_challenge(params, ENV['INSTAGRAM_VERIFY_TOKEN'])
when :post
Instagram.process_subscription(request.body.read) do |handler|
handler.on_user_changed do |user_id, data|
media_id = (data['data'] || {})['media_id']
InstagramJob.perform_later user_id, media_id
@zosiu
zosiu / 0-post-checkout-branch-logging.md
Last active August 29, 2015 14:22
git post-checkout branch logging
git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
  • create ~/.tig-brother/checkouts.db (sqlite3) from the dump

  • copy the hook script

  • git init in the git repo

@zosiu
zosiu / wk_wallpaper.rb
Created July 25, 2015 15:35
WaniKani wallpaper
#!/usr/bin/env ruby
require 'wanikani'
Wanikani.api_key = 'YOUR_WANIKANI_API_KEY'
wanikani_kanji_data = Wanikani::Level.kanji(*(1..60))
def color_for(item)
case (item['user_specific'] || {})['srs']
when 'apprentice' then '#dd0093'
@zosiu
zosiu / nisemonogatari.yml
Created September 6, 2015 23:22
nisemonogatari kanji
- - "お前"
- :count: 325
:readings:
- "オマエ"
- - "木"
- :count: 285
:readings:
- "キ"
- - "言う"
- :count: 279
@zosiu
zosiu / checker.rb
Created October 20, 2015 01:18
When can I read [X]? - WaniKani Level Checker
#!/usr/bin/env ruby
require 'yaml'
require 'mojinizer'
text = STDIN.read
kanjidb = YAML.load_file('kanji_levels.yml')
kanji = text.chars.select { |ch| ch.kanji? }.uniq
@zosiu
zosiu / countries-without-postcodes.rb
Created November 13, 2015 10:25
Countries without postal codes
COUNTRIES_WITHOUT_POSTCODES = [
[ "Angola", "AO" ],
[ "Antigua and Barbuda", "AG" ],
[ "Aruba", "AW" ],
[ "Bahamas", "BS" ],
[ "Belize", "BZ" ],
[ "Benin", "BJ" ],
[ "Botswana", "BW" ],
[ "Burkina Faso", "BF" ],
[ "Burundi", "BI" ],
@zosiu
zosiu / critical_hit
Created December 5, 2015 01:08
Hipchat status change
#!/bin/bash
# usage: critical_hit HIPCHAT_API_KEY HIPCHAT_USER_ID_OR_EMAIL
(./set_hipchat_status $1 $2 dnd; sleep 2h; ./set_hipchat_status $1 $2 chat) &

KC60 Keyboard end-user tips, tricks, programming notes, etc.

Leimi's note: removed lots of stuff from the original gist of scottjl, (thanks to him by the way!), as in the end some wasn't useful for me. If you are intestered, go check the gist revisions.

The KC60 is kinda like a premade GH60 that was first sold on Massdrop during summer 2015.
It runs on TMK firmware, or something based on it at least (not sure this is the real source for the keyboard but it seems it is), which means it's heavily programmable.
There is a GUI tool (the source of this tool seems to be here) and a command-line tool to ease up the process of programming the board.
**Go check this great article on Key

@zosiu
zosiu / whiteboardCleaner.md
Created August 5, 2016 18:45 — forked from lelandbatey/whiteboardCleaner.md
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results