Skip to content

Instantly share code, notes, and snippets.

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

DreamPiggy dreampiggy

:octocat:
Work
View GitHub Profile
@dreampiggy
dreampiggy / Singleton.java
Created June 14, 2016 13:48
Java Singleton
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 / csgoboost.sh
Created May 26, 2016 12:13
Counter-Strike Global Offensive OS X Boost
#!/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
@dreampiggy
dreampiggy / Clone.js
Last active June 14, 2016 13:49
Clone object in JavaScript
'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 / QuickSort.swift
Last active June 14, 2016 13:49
QuickSort in 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 / 0_reuse_code.js
Created March 14, 2016 06:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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