Skip to content

Instantly share code, notes, and snippets.

@CoderPiF
CoderPiF / ArrayIterator.h
Last active December 12, 2016 15:16
给你一个嵌套的 NSArray 数据,实现一个迭代器类,该类提供一个 next() 方法,可以依次的取出这个 NSArray 中的数据。
#import <Foundation/Foundation.h>
@interface ArrayIterator : NSObject
@property (nonatomic, strong) NSArray *array;
- (id) next;
- (NSArray *) allObjects;
@end
@CoderPiF
CoderPiF / build_openssl_dylib.sh
Last active December 27, 2016 08:15 — forked from tmiz/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
OPENSSL_VERSION="1.0.2j"
curl -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
@CoderPiF
CoderPiF / NumberOfIslands.c
Created February 10, 2017 05:58
LeetCode 200. Number of Islands
int findTop(int *flag, int i) {
while (flag[i] != i) i = flag[i];
return i;
}
void mergeSet(int *flag, int i, int j) {
int x = findTop(flag, i);
int y = findTop(flag, j);
flag[x] = y;
}
@CoderPiF
CoderPiF / VimLauncher.scpt
Last active February 20, 2023 09:06
open file with vim in iTerm2 by double click
on run {input, parameters}
set the_path to POSIX path of input
set cmd to "vim '" & the_path & "'"
set isRunning to (application "iTerm" is running)
tell application "iTerm"
activate
if isRunning then
if (count of windows) > 0 then
set sess to (current session of (create tab with default profile of current window))
else
@CoderPiF
CoderPiF / .osx
Created February 17, 2017 02:19 — forked from ryanpcmcquen/.osx
.osx
#!/usr/bin/env bash
## Adapted from:
## https://mths.be/osx & https://github.com/ssorallen/dotfiles/blob/master/.osx
##
## curl -O https://gist.githubusercontent.com/ryanpcmcquen/b2e608311f286a4ab3e1/raw/.osx
###############################################################################
# General UI/UX #
###############################################################################
@CoderPiF
CoderPiF / UsingRSAKeyLoginSSH.sh
Last active July 6, 2017 10:35
服务器屏蔽密码登录,开启钥匙串登录
#!/bin/bash
# Usage : curl -O https://gist.githubusercontent.com/CoderPiF/14ae6e3fea7e2914679b3277c19cba4a/raw/UsingRSAKeyLoginSSH.sh && sh UsingRSAKeyLoginSSH.sh
ConfigFile=/etc/ssh/sshd_config
cp ${ConfigFile} ${ConfigFile}.bak
sed -i -e '/RSAAuthentication/d' ${ConfigFile}
echo 'RSAAuthentication yes' >> ${ConfigFile}
sed -i -e '/PubkeyAuthentication/d' ${ConfigFile}
#!/bin/bash
# Usage : curl -O https://gist.githubusercontent.com/CoderPiF/f091f6ddcc80eba9be0c1d49d83179ca/raw/SetupShadowsocks.sh && sh SetupShadowsocks.sh my.shadowsocks.password
sudo apt-get install python-setuptools
curl -O https://codeload.github.com/shadowsocks/shadowsocks/tar.gz/2.9.1
tar -xzf 2.9.1
rm 2.9.1
cd shadowsocks-2.9.1
python setup.py install
@CoderPiF
CoderPiF / my_shell_setup.sh
Last active July 6, 2017 10:33
oh my zsh + spf13-vim
#!/bin/bash
# Usage : curl -O https://gist.githubusercontent.com/CoderPiF/eef90b89a93a1a699ebd738b51d02ab2/raw/my_shell_setup.sh && sh my_shell_setup.sh
apt-get install zsh
apt-get install git-core
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
chsh -s `which zsh`