Skip to content

Instantly share code, notes, and snippets.

View yeahdongcn's full-sized avatar

R0CKSTAR yeahdongcn

View GitHub Profile
@ehabkost
ehabkost / make-bridge-for-libvirt.sh
Created May 7, 2010 15:08
Very small qemu-ifup script
#!/bin/bash
# make-bridge-for-libvirt.sh
#
# This scripts follows blindly the instructions from:
# http://wiki.libvirt.org/page/Networking#Fedora.2FRHEL_Bridging
#
# It tries to copy the existing physical network config
# to the bridge. It may not work if you have a non-trivial
# network setup on ifcfg-eth0.
#
@wibron
wibron / gist:1152143
Created August 17, 2011 17:52
Run shell-command with Applescript as root
-- The shellscript:
-- #!/bin/sh
-- sudo mount_nfs -P 192.168.0.1:sharename ~/localPath
tell application "Terminal"
do shell script "~/.shellscript.sh" password "yourpassword" with administrator privileges
quit
end tell
@iksky
iksky / Mac下开机自动连接ssh -D.txt
Created November 16, 2011 02:11
Mac下开机自动连接ssh -D
首先我们来生成公钥文件。Terminal下面输入
ssh-keygen -t rsa
之后在Terminal的提示里按回车。直到生成id_rsa.pub文件,生成的id_rsa.pub文件在 ~/.ssh下面。Terminal下面输入
cd ~/.ssh
cp id_rsa.pub authorized_keys
上面第一句的意思是进入~/.ssh文件夹,第二句是复制id_rsa.pub为authorized_keys文件。
@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
@jasongregori
jasongregori / gist:2821444
Created May 28, 2012 22:18
weakself code snippet: my most used code snippet
__weak __typeof(&*self)weakself = self;
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@chockenberry
chockenberry / gist:11056920
Last active October 22, 2020 19:23
NSFont+SystemFont
//
// NSFont+SystemFont.h
// xScope
//
// Created by Craig Hockenberry on 4/17/14.
//
// Thanks to http://nshipster.com/method-swizzling/
#import <Cocoa/Cocoa.h>
@yeahdongcn
yeahdongcn / gist:42ca950a32c1f04aedfa
Created July 25, 2014 06:12
Install JDK7 on 10.10
To install it follow these steps:
Download JDK 7
Open the DMG
Run pkgutil --expand "/Volumes/JDK 7 Update 60/JDK 7 Update 60.pkg" "/tmp/JDK 7 Update 60.unpkg"
Go to /tmp/JDK 7 Update 60.unpkg
Open the Distribution file in your favorite editor (I recommend (Sublime Text)[http://www.sublimetext.com])
Change the function pm_install_check() to always return true
Run pkgutil --flatten "/tmp/JDK 7 Update 60.unpkg" "/tmp/JDK 7 Update 60.pkg"
Run open "/tmp/JDK 7 Update 60.pkg"
@huqi
huqi / trial.key
Created April 11, 2015 09:01
Beyond Compare 4 license for Mac
Beyond Compare 4
Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Windows
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
@maxim
maxim / gh-dl-release
Last active June 5, 2024 21:11
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#