Skip to content

Instantly share code, notes, and snippets.

@m039
m039 / tounix.c
Created Jun 10, 2011
Convert file from mac(\r)/unix(\n)/dos(\r\n) formats to the unix format
View tounix.c
/* Author: m039 <flam44 (at) gmail (dot) com> */
#include <stdio.h>
#include <stdlib.h>
static FILE *src;
static FILE *dst;
int main(int argc, char **argv) {
int c;
@m039
m039 / utf8.c
Created Jun 12, 2011
Print a katakana table to the stdout in the utf8 format.
View utf8.c
/* Author: m039 <flam44 (at) gmail (dot) com> */
#include <stdio.h>
/* Code point ranges */
#define MINUSCULE 0x000d8 /* 0 to 7F */
#define ALPHA 0x00251 /* 80 to 7FF */
#define KATAKANA_NI 0x030A0 /* 800 to FFFF */
#define CLEF 0x1D11E /* 10000 to 10FFFF */
@m039
m039 / utf16_to_utf8.c
Created Jun 12, 2011
Print a content of an utf16 file to the stdout.
View utf16_to_utf8.c
/* Author: m039 <flam44 (at) gmail (dot) com> */
#include <stdio.h>
/*
* Use the next command to test this snippet:
*
* iconv -f utf8 -t utf16 utf8.txt -o utf16.txt
* ./utf16_to_utf8 utf16.txt > utf8.txt
*/
@m039
m039 / js-protection-methods.clj
Created Jun 30, 2011
This script is for fun with clojure and some javascript protection mechanism.
View js-protection-methods.clj
;; Author: m039 <flam44 (at) gmail (dot) com>
;;
;; Some cracking methods to decrypt urls from javascript protected
;; site. All the methods for manual usage.
;;
;; The protection should be based on this
;; [http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_60.html]
;; script.
;; alpha
@m039
m039 / get_sound.sh
Created Jul 24, 2011
Get an audio file from the Google Translate.
View get_sound.sh
#!/bin/sh
# Author: m039 <flam44 (at) gmail (dot) com>
wget --user-agent --referer='http://translate.google.com' "http://translate.google.com/translate_tts?ie=UTF-8&tl=ja&q=$1" -O ~/.anki/decks/MNN\ I.media/${1}.mp3
@m039
m039 / to_ogv.sh
Created Aug 3, 2011
Convert file from .flv to .ogv via ffmpeg
View to_ogv.sh
#!/bin/sh
# Author: m039 <flam44 (at) gmail (dot) com>
# usage: ./to_ogv.sh <path to .flv file> <path to .ogv file>
ffmpeg -i ${1} -f ogg -vcodec libtheora -acodec libvorbis ${2}
@m039
m039 / fb.el
Created Jan 25, 2012
get likes/comments count from the facebook
View fb.el
;; -*- mode: emacs-lisp; -*-
(require 'mm-uu)
(require 'json)
(require 'url)
(defvar facebook-access-token nil)
(defvar facebook-retrive-limit 1000)
(defun facebook-set-access-token (token)
@m039
m039 / sicp.scm
Created Feb 3, 2012
sicp exercise
View sicp.scm
;; Exercise 1.16
(define (fast-expt-iter acc i n b)
(cond ((= n 0) acc)
((= i 0) (fast-expt-iter b 1 (- n 1) b))
((= i 1) (fast-expt-iter (* b b) 2 (- n 1) b))
((>= (- n i) 0) (fast-expt-iter (* acc acc) (+ i i) (- n i) b))
(else (* acc (fast-expt-iter acc 0 n b)))))
(define (fast-expt b n)
@m039
m039 / quote.sh
Created Feb 4, 2013
Grab a quote from http://iheartquotes.com/api, generate image with the quote and embed it into wallpaper. (raw version)
View quote.sh
#!/bin/sh
#
# quote api
#
alias getfortune='wget --timeout=3 -O - -q'
alias fortune='getfortune http://www.iheartquotes.com/api/v1/random'
alias myfortune='getfortune http://www.iheartquotes.com/api/v1/random?source=forrestgump'
@m039
m039 / iheartquotes.sh
Last active Dec 12, 2015
Shell script of usage http://iheartquotes.com/api and imagemagic to generate the quote.png
View iheartquotes.sh
#!/bin/sh
##
## iheartquotes api
##
alias getfortune='wget --timeout=3 -O - -q'
alias fortune='getfortune http://www.iheartquotes.com/api/v1/random'
alias myfortune='getfortune http://www.iheartquotes.com/api/v1/random?source=humorix_misc'