Skip to content

Instantly share code, notes, and snippets.

@m039
m039 / gist:8384823
Created January 12, 2014 13:55
android stuff
# clean application data
adb shell pm clear com.android.browser
;; Playing with racket
(require net/url)
(require json)
(require rnrs/io/ports-6)
(define link "http://graph.facebook.com/")
(define (get-username id)
(let ((ht (call-with-port (get-pure-port (string->url (string-append link id)))
(lambda (p)
@m039
m039 / shadow.xml
Created May 13, 2013 22:31
It is very strange feeling to write xml files for android like this in emacs.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
(truncate (* 255 0.2))51 (#o63, #x33, ?3)
<gradient
android:startColor="#4C000000"
@m039
m039 / iheartquotes.sh
Last active December 12, 2015 03:58
Shell script of usage http://iheartquotes.com/api and imagemagic to generate the quote.png
#!/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'
@m039
m039 / quote.sh
Created February 4, 2013 02:37
Grab a quote from http://iheartquotes.com/api, generate image with the quote and embed it into wallpaper. (raw version)
#!/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 / sicp.scm
Created February 3, 2012 10:51
sicp exercise
;; 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 / fb.el
Created January 25, 2012 13:10
get likes/comments count from the facebook
;; -*- 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 / to_ogv.sh
Created August 3, 2011 16:00
Convert file from .flv to .ogv via ffmpeg
#!/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 / js-protection-methods.clj
Created June 30, 2011 14:02
This script is for fun with clojure and some javascript protection mechanism.
;; 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 / utf16_to_utf8.c
Created June 12, 2011 19:35
Print a content of an utf16 file to the stdout.
/* 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
*/