Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

DreamPiggy dreampiggy

🌴
On vacation
Block or report user

Report or block dreampiggy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dreampiggy
dreampiggy / gist:bfb42393395e57a1117e
Last active May 11, 2016 — forked from fabiofl/gist:5873100
Clear Mac OS X's icon cache.
View gist:bfb42393395e57a1117e
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
@dreampiggy
dreampiggy / 0_reuse_code.js
Created Mar 14, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dreampiggy
dreampiggy / QuickSort.swift
Last active Jun 14, 2016
QuickSort in Swift
View QuickSort.swift
func quicksort<T: Comparable>(a: [T]) -> [T] {
if a.count <= 1 {
return a
} else {
let pivot = a[a.count/2]
let less = a.filter { $0 < pivot }
let equal = a.filter { $0 == pivot }
let greater = a.filter { $0 > pivot }
return quicksort(less) + equal + quicksort(greater)
}
@dreampiggy
dreampiggy / Clone.js
Last active Jun 14, 2016
Clone object in JavaScript
View Clone.js
'use strict';
function clone(obj) {
if (obj == null || typeof obj != "Object") {
return obj;
}
let copy = obj.constructor();
for (let attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = obj[attr];
}
@dreampiggy
dreampiggy / csgoboost.sh
Created May 26, 2016
Counter-Strike Global Offensive OS X Boost
View csgoboost.sh
#!/bin/bash
ROOT_PWD="your_root_password"
CSGO_ID=`ps aux | grep csgo_osx64 | grep -v grep | awk '{print $2}'`
if [ -n "$CSGO_ID" ]; then
$(echo $ROOT_PWD | sudo -S renice -20 -p $CSGO_ID >/dev/null 2>&1)
echo "CSGO Boost Success"
else
echo "CSGO Boost Fail"
fi
View Singleton.java
public class Singleton {
private volatile static Singleton singleton;
private Singleton (){}
public static Singleton getSingleton() {
if (singleton == null) {
synchronized (Singleton.class) {
if (singleton == null) {
singleton = new Singleton();
}
}
@dreampiggy
dreampiggy / QuickSort.m
Created Jun 17, 2016
QuickSort-Objective-C
View QuickSort.m
void quicksortInPlace(NSMutableArray *array, NSInteger first, NSInteger last, NSComparator comparator) {
if (first >= last) return;
id pivot = array[(first + last) / 2];
NSInteger left = first;
NSInteger right = last;
while (left <= right) {
while (comparator(array[left], pivot) == NSOrderedAscending)
left++;
while (comparator(array[right], pivot) == NSOrderedDescending)
right--;
@dreampiggy
dreampiggy / example.md
Created Jul 2, 2016 — forked from ericclemmons/example.md
HTML5 <details> in GitHub
View example.md

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
@dreampiggy
dreampiggy / _service.md
Created Jul 19, 2016 — forked from naholyr/_service.md
Sample /etc/init.d script
View _service.md

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)
@dreampiggy
dreampiggy / thunder
Last active Jul 19, 2016
Thunder Xware boot service for Raspberry Pi or NAS
View thunder
#! /bin/sh
# /etc/init.d/thunder
### BEGIN INIT INFO
# Provides: thunder
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Thunder Server at boot time
You can’t perform that action at this time.