Skip to content

Instantly share code, notes, and snippets.

View seymores's full-sized avatar

Teo Choong Ping seymores

View GitHub Profile
@seymores
seymores / AndroidManifestDecompressor.groovy
Created April 20, 2012 03:33
Extract AndroidManifest.xml information.
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
class AndroidXMLDecompress {
// decompressXML -- Parse the 'compressed' binary form of Android XML docs
// such as for AndroidManifest.xml in .apk files
sudo yum groupinstall "Development Tools"
sudo yum install openssl-devel.x86_64
sudo yum install ncurses-devel
# Install latest Erlang
wget http://erlang.org/download/otp_src_20.3.tar.gz
tar xvfz otp_src_20.3.tar.gz
cd otp_src_20.3
make
sudo make install
@seymores
seymores / IrcClient.scala
Created September 20, 2011 13:55
Simple Scala Irc client
import java.net._
import java.io._
import scala.io._
import scala.util.control.Breaks._
val server = "irc.freenode.net";
val nick = "SeymourCakes"
val login = "SeymourCakesBot"
val channel = "#myoss"
val socket = new Socket(server, 6667)
@seymores
seymores / gcm-clojure.clj
Last active September 9, 2017 13:54
Use gcm-server from clojure
;;; Project here: https://github.com/seymores/gcm-clj
;;;
;;; Note: you need to specify the custom repo to get gcm-server.jar
;;; :repositories [["google" "https://github.com/slorber/gcm-server-repository/raw/master/releases"]]
;;; :dependencies [[com.google.android.gcm/gcm-server "1.0.2"]]
;;;
;;; See http://developer.android.com/google/gcm/gs.html#server-app
;; Import all the needed classes from gcm-server.jar
(import (com.google.android.gcm.server Sender Message Message$Builder MulticastResult))
@seymores
seymores / ethermine.10m.rb
Last active June 19, 2017 04:12
Ethermine BitBar Plugin
#!/usr/bin/env ruby
# <bitbar.title>Ethermine BitBar Plugin</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Seymour Cakes</bitbar.author>
# <bitbar.author.github>https://gist.github.com/seymores/4cf112d09262a615c3cbf39b91e01207</bitbar.author.github>
# <bitbar.desc>Quick latest hashrate and unpaid values.</bitbar.desc>
# <bitbar.dependencies>ruby,httparty</bitbar.dependencies>
require 'httparty'
@seymores
seymores / carousell.txt
Created April 27, 2017 07:57
Crawling Carousell Part 2
iex(8)> c1 = "https://carousell.com/ui/iso/api-main;localeCookies=true;path=%2F2.1%2Fproducts%2F;query=%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22lowest_price%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex%20explorer%2039mm%202016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D?_csrf=lY4VP8gA-VL4l1oTBrjxzVwVWronwIMzSPFQ&returnMeta=true"
"https://carousell.com/ui/iso/api-main;localeCookies=true;path=%2F2.1%2Fproducts%2F;query=%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22lowest_price%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex%20explorer%2039mm%202016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D?_csrf=lY4VP8gA-VL4l1oTBrjxzVwVWronwIMzSPFQ&returnMeta=true"
iex(9)> URI.decod
defmodule MyApp.EncryptedField do
@behaviour Ecto.Type
def type, do: :binary
def cast(value) do
{:ok, to_string(value)}
end
# This is called when the field value is about to be written to the database
@seymores
seymores / question1.clj
Created January 17, 2017 16:39
Description of Question 1 solution.
;; Hardcode the input data here as `data`
(def data `({:content "Message from User 2"
:from {:id 2 :name "User 2" :type :user :updated "2000-03-05T16:49:56.845Z"}
:to {:id 22 :name "Group 22" :type :group :updated "1991-10-19T00:57:39.527Z"}
:type :message}
{:content "Message from User 1"
:from {:id 1 :name "User 1" :type :user :updated "1980-07-21T18:56:27.379Z"}
:to {:id 3 :name "User 3" :type :user :updated "1984-05-16T19:57:44.739Z"}
@seymores
seymores / ref_consistency_multithreaded_test.clj
Last active January 17, 2017 16:40
Description of solution for Question 2. Test for ref consistency in multi-threaded environment
;; Question 2
;; 1. Create a unit test that reproduces the problem
;; 2. Explain what is going wrong
;; 3. Fix the bug
;; 0. Start with the ref a, ref b and the advance-* functions
(def a (ref 1))
(def b (ref 1))
Algorithmia = require("algorithmia");
const request = require('request');
exports.apply = function(input, cb) {
let url = 'http://104.196.34.244:80/' + input;
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
out = body