Skip to content

Instantly share code, notes, and snippets.

View h4ck4life's full-sized avatar

Alif h4ck4life

  • Dev.
  • Kuala Lumpur
View GitHub Profile
@h4ck4life
h4ck4life / sc-dl.js
Created March 6, 2012 02:56 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
{
"ANDROID_VERSION": 1.5,
"APP_VERSION_CODE": 8,
"APP_VERSION_NAME": 1.3,
"AVAILABLE_MEM_SIZE": 181972992,
"BRAND": "generic",
"BUILD": {
"BOARD": "unknown",
"BRAND": "generic",
"DEVICE": "generic",
@h4ck4life
h4ck4life / gist:6433506
Created September 4, 2013 06:51
Android blow detection via microphone. Source: http://stackoverflow.com/a/6186977
public boolean isBlowing()
{
boolean recorder=true;
int minSize = AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
AudioRecord ar = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000,AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT,minSize);
short[] buffer = new short[minSize];
@h4ck4life
h4ck4life / logismo.js
Created September 10, 2013 16:16 — forked from ericf/logismo.js
YUI.add('logismo', function(Y) {
/**
* Logismo
*/
var Logismo,
LOGISMO = 'logismo',
EVENTS_RESOURCE_PATH = 'eventsResourcePath',
<!DOCTYPE HTML>
<html>
<head>
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="app"></div>
<script>
@h4ck4life
h4ck4life / temperatureSensor
Created October 2, 2013 18:11
Arduino Uno R3 temperature sensor + buzzer sample code. Read more here: http://alif.my/2013/10/project-2-temperature-sensor-buzzer/
float temp;
int tempPin = 0;
int buzzer=8; //Connect the buzz positive Pin to Digital Pin 8
void setup()
{
pinMode(buzzer,OUTPUT); //Set Pin Mode as output
Serial.begin(9600);
beep(500);
int photoRPin = 0;
int minLight;
int maxLight;
int lightLevel;
int adjustedLightLevel;
void setup(){
//Setup the starting light level limits
lightLevel=analogRead(photoRPin);
@h4ck4life
h4ck4life / R.layout.list_item_search_autocomplete
Created October 11, 2013 20:39
Android AutoCompleteTextView example code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/search_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
@h4ck4life
h4ck4life / code_exec_profile
Created November 1, 2013 01:00
Java Code Execution Time Calculation
long start = System.nanoTime();
// do work.....
long time = System.nanoTime() - start;
double timeInSeconds = time/1e9;