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 / 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
@steipete
steipete / PSPDFGenerics.h
Last active April 28, 2020 15:08
Override copy and mutableCopy on Objective-C collection classes to pass along both the collection type and the generic info. This is a header-only "library". MIT licensed. Craving for more? foreach: https://gist.github.com/steipete/7e3c69b985165dc23c5ec169b857ff42 even more: https://pspdfkit.com/blog/2016/swifty-objective-c/ - ships in https://p…
//
// PSPDFGenerics.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
/**
@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);
@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)
}
@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 {} \;
@joshuakraemer
joshuakraemer / instructions.md
Last active June 2, 2023 10:23
How to install Windows Media Player 11 to a Proton prefix
  1. Download Windows Media Player 11, 64 bit (wmp11-windowsxp-x64-enu.exe):
    $ cd /tmp/
    $ curl -O https://web.archive.org/web/20190512112704/https://download.microsoft.com/download/3/0/8/3080C52C-2517-43DE-BDB4-B7EAFD88F084/wmp11-windowsxp-x64-enu.exe
  2. Extract the archive:
    $ cabextract wmp11-windowsxp-x64-enu.exe -d wmp11
  3. Run and close the game through Steam. A Proton prefix is created on the first run.
  4. Go to the game's folder inside Steam's compatdata folder:
    $ cd $HOME/.local/share/Steam/steamapps/compatdata/287290
  5. Set prefix to Windows XP: $ WINEPREFIX=$PWD/pfx wine winecfg
@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) {
@steipete
steipete / SpinlockTestTests.swift
Last active August 29, 2023 08:47 — forked from RomanTruba/Synchronization_test_iOS_SDK10
Updated for Xcode 8, Swift 3; added os_unfair_lock
//
// SpinlockTestTests.swift
// SpinlockTestTests
//
// Created by Peter Steinberger on 04/10/2016.
// Copyright © 2016 PSPDFKit GmbH. All rights reserved.
//
import XCTest
@rambolee
rambolee / update-dnsmasq-from-gfwlist.py
Last active September 22, 2023 09:48
升级 小米路由器3 可以ssh 可以 Shadowsocks [Tags]: 小米路由, 小米路由3, 小米路由器, 小米路由器3, ssh, shadowsocks
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)