Skip to content

Instantly share code, notes, and snippets.

View dreampiggy's full-sized avatar
:octocat:
Work

DreamPiggy dreampiggy

:octocat:
Work
View GitHub Profile
@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
@wbroek
wbroek / genymotionwithplay.txt
Last active February 12, 2024 03:22
Genymotion with Google Play Services for ARM
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
@dankogai
dankogai / peekFunc.swift
Last active February 28, 2023 15:38
Get the internal function pointer in swift
/// See
/// https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift
/// https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c
/// to find why this works
func peekFunc<A,R>(f:A->R)->(fp:Int, ctx:Int) {
let (hi, lo):(Int, Int) = reinterpretCast(f)
let offset = sizeof(Int) == 8 ? 16 : 12
let ptr = UnsafePointer<Int>(lo+offset)
return (ptr.memory, ptr.successor().memory)
}
@hax
hax / safe_json_encode.php
Last active May 13, 2021 08:30
PHP safe json encode
<?php
function safe_json_encode($data) {
// We might have been tolerant to some common cases such as convert
// INF/NAN as 0 by using JSON_PARTIAL_OUTPUT_ON_ERROR option, but
// sadly `json_last_error()` only get the last error means it may
// override worse errors such as malfored utf-8 which we can't ignore!
// Poor H P !!
$result = @json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
@bang590
bang590 / linkmap.js
Last active August 19, 2023 15:24
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {

CLang optimizations on Mac OSX

Version:

Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

This was made with commands:

@jtbandes
jtbandes / decode-dyn-uti.swift
Last active January 7, 2024 05:29
Dynamic UTI decoding
/// Decodes a dynamically-generated Uniform Type Identifier for inspection purposes. (**NOT FOR PRODUCTION USE!**)
/// Many, many thanks to http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/
///
/// <https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-BCGCDHIJ>
func decodeDynUTI(_ uti: String) -> String?
{
let vec = Array("abcdefghkmnpqrstuvwxyz0123456789")
let encoded = Array(uti).suffix(from: 5)
var result: [UInt8] = []
@dreampiggy
dreampiggy / gist:bfb42393395e57a1117e
Last active May 11, 2016 10:01 — forked from fabiofl/gist:5873100
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ \
-name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders/ \
-name com.apple.iconservices -exec rm -rf {} \;
sudo rm -rf /Library/Caches/com.apple.iconservices.store
@subfuzion
subfuzion / curl.md
Last active March 28, 2024 23:11
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.