Skip to content

Instantly share code, notes, and snippets.

@HackingGate
HackingGate / ScrollView.m
Created May 9, 2015 04:09
Keyboard dismiss when scrollView drag.
@interface ScrollView <UIScrollViewDelegate,UITextFieldDelegate> {
UITextField *_currentTF;
}
@implementation
- (void)viewDidLoad {
yourScrollView.delegate = self;
yourTextField.delegate = self;
}
@HackingGate
HackingGate / MySingletonClass.m
Created May 26, 2015 02:17
Objective-C SingletonClass in GCD
#import "MySingletonClass.h"
static MySingletonClass *singleton = nil;
@implementation MySingletonClass
+ (MySingletonClass *)defaultSingleton{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
singleton = [[MySingletonClass alloc] init];
@HackingGate
HackingGate / updateBuildNumber.sh
Created August 24, 2015 02:14
Insert Subversion revision number in Xcode
REV_GIT=`git svn info |grep Revision: |cut -c11-`
REV_SVN=`svn info |grep Revision: |cut -c11-`
if [ -z $REV_GIT ] ;then
REV=$REV_SVN
else
REV=$REV_GIT
fi
echo "REV is $REV"
BASEVERNUM=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${INFOPLIST_FILE}"`
@HackingGate
HackingGate / MetadataObjectTypes.swift
Last active September 7, 2015 03:14
All iOS Available Metadata Object Types
// Available types : https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVMetadataMachineReadableCodeObject_Class/index.html#//apple_ref/doc/constant_group/Machine_Readable_Object_Types
import AVFoundation
let metadataObjectTypes = [
AVMetadataObjectTypeUPCECode,
AVMetadataObjectTypeCode39Code,
AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeEAN13Code,
AVMetadataObjectTypeEAN8Code,
AVMetadataObjectTypeCode93Code,
@HackingGate
HackingGate / busterGenerate.sh
Last active September 27, 2015 05:11
A script to use buster generate static ghost website and fix something..
#!/bin/bash
LOCALHOST=http://localhost:2368
URL=http://hackinggate.com
LOCALDOMAIN=localhost:2368
DOMAIN=hackinggate.com
buster generate --domain=$LOCALHOST
#get rss & sitemap
wget -O- http://127.0.0.1:2368/rss/ > ./static/rss/index.html
@HackingGate
HackingGate / pdnsd.conf
Last active April 18, 2016 10:02
pdnsd.conf for openwrt
global {
perm_cache=2048;
cache_dir="/var/pdnsd";
# pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 0.0.0.0; # Use eth0 here if you want to allow other
# machines on your network to query pdnsd.
server_port = 25252;
status_ctl = on;
# paranoid=on; # This option reduces the chance of cache poisoning
import MediaPlayer
class ShutterSoundCanceller {
static func playShutterInvertSound() {
if let soundURL = Bundle.main.url(forResource: "photoShutterAntiSound", withExtension: "caf") {
do {
// Play sound even in silent mode
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeMeasurement, options: [])
} catch {
print(error)
@HackingGate
HackingGate / cocoapods_aliases
Last active October 12, 2018 13:45
CocoaPods Aliases
# CocoaPods aliases
alias pod_install_quick="pod install --no-repo-update"
alias pod_update_quick="pod update --no-repo-update"
alias pod_repo_update="pod repo update"
@HackingGate
HackingGate / himawari.js
Last active October 24, 2018 00:05
Set latest himawari earth dynamic wallpaper in every 10 minutes for macOS (ひまわり8号リアルタイム壁紙)
const { exec } = require('child_process');
var glob = require("glob")
var cronTime = '*/10 * * * *';
CronJob = require('cron').CronJob;
var job = new CronJob({
cronTime: cronTime,
onTick: function() {
@HackingGate
HackingGate / set-himawari-wallpaper.sh
Last active May 6, 2019 08:20
Set himawari wallpaper shell script for macOS. (Linux & Windows not tested)
#!/bin/bash
PATH=$PATH:/usr/local/bin
echo `date`
echo "Checking himawari"
if ! type himawari > /dev/null; then
echo "Install himawari with:"
echo
echo "brew install imagemagick"