This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get and Set Hostname | |
sudo scutil --get HostName | |
sudo scutil --get ComputerName | |
sudo scutil --get LocalHostName | |
hostname | |
sudo scutil --set HostName billMacMini | |
# Disable automount folder, modify /etc/auto_master, comment the "home" line | |
# Finally, restart the Mac, if you think it's cumbersome, use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PRIMARYGROUP="Domain Users" | |
gen_apple_id() | |
{ | |
set -x | |
local NAME=$1 | |
local TYPE=$2 | |
echo name: $NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "ibase=16; AB7833DF" | bc | |
echo "obase=2; 4294967295" | bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
let workingQueue = dispatch_queue_create("myqueue", nil) | |
dispatch_async(workingQueue) { | |
print("working hard...") | |
NSThread.sleepForTimeInterval(2) | |
dispatch_async(dispatch_get_main_queue()){ | |
print("Work Done, updateUI") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git revert HEAD~n..HEAD~m | |
回滚区间[HEAD~n + 1, HEAD~m]上的commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let image = UIImage(named: "car.jpg") | |
let hasAlpha = false | |
let scale: CGFloat = 0.0 // Automatically use scale factor of main screen | |
UIGraphicsBeginImageContextWithOptions(CGSize(width: 80, height:80), !hasAlpha, scale) | |
image?.draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: 80, height: 80))) | |
let scaledImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CharacterSet { | |
var characters:[UnicodeScalar] { | |
var chars = [UnicodeScalar]() | |
for plane:UInt8 in 0...16 { | |
if self.hasMember(inPlane: plane) { | |
let p0 = UInt32(plane) << 16 | |
let p1 = (UInt32(plane) + 1) << 16 | |
for c:UInt32 in p0..<p1 { | |
if let us = UnicodeScalar(c) { | |
if self.contains(us) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to Oh My Fish install. | |
set -q XDG_DATA_HOME | |
and set -gx OMF_PATH "$XDG_DATA_HOME/omf" | |
or set -gx OMF_PATH "$HOME/.local/share/omf" | |
# Load Oh My Fish configuration. | |
source $OMF_PATH/init.fish | |
set -x PATH $PATH ~/GitRepo/depot_tools | |
set -x PATH $PATH ~/.cargo/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<netinet/in.h> | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<sys/socket.h> | |
#include<sys/stat.h> | |
#include<sys/types.h> | |
#include<unistd.h> | |
int main() { | |
int create_socket, new_socket; |
OlderNewer