Skip to content

Instantly share code, notes, and snippets.

View neonichu's full-sized avatar
🤬
GitHub, cancel your contract with ICE!

Boris Bügling neonichu

🤬
GitHub, cancel your contract with ICE!
View GitHub Profile
@neonichu
neonichu / my_path.swift
Created July 17, 2015 17:21
Print the path to the program being executed
#!/usr/bin/env swift
import Foundation
var path = (Process.arguments[0] as NSString)
path = path.stringByDeletingLastPathComponent
path = String(CString:realpath(path.cStringUsingEncoding(NSUTF8StringEncoding), nil),
encoding: NSUTF8StringEncoding)!
print("\(path) \n")
@neonichu
neonichu / blocklist.csv
Created June 18, 2015 17:27
The list of Twitter accounts @neonacho blocks as of 20150618
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
14513878
13185872
138908422
3036621918
168831662
113138090
28338715
14789498
148207025
5501422
@neonichu
neonichu / zama.rb
Created May 27, 2015 18:47
Do a development Pod install and archive the corresponding framework via Carthage automatically.
#!/usr/bin/env ruby
require 'cocoapods'
require 'fileutils'
def podfile_from_spec(spec)
podfile = File.open('Podfile', 'w')
podfile.write(<<-EOF
platform :ios, '8.0'
@neonichu
neonichu / web.rb
Created May 25, 2015 13:22
GitHop web app
require 'githop'
require 'sinatra'
def githop_html(user)
config = {
'bigquery' => {
'client_id' => ENV['BIGQUERY_CLIENT_ID'],
'service_email' => ENV['BIGQUERY_SERVICE_EMAIL'],
'keyfile' => ENV['BIGQUERY_KEYFILE'],
'project_id' => ENV['BIGQUERY_PROJECT_ID']
@neonichu
neonichu / manius.rb
Last active August 29, 2015 14:21
Script for creating a dummy Xcode project which makes Carthage do its work.
#!/usr/bin/env ruby
require 'fileutils'
require 'xcodeproj'
# Find all workspaces, but reject the subproject ones
workspaces = Dir.glob('**/*.xcworkspace').reject { |w| w.end_with?('project.xcworkspace') }
schemes = workspaces.map do |workspace|
# Find all pod targets
targets = `xcodebuild -workspace #{workspace} -list 2>&1`.split("\n").select { |t| t.match(/Pods/) }
@neonichu
neonichu / yolo.sh
Created May 15, 2015 16:33
Mentions of `wireless` in the Xcode 6.3.1 runtime headers
$ grep -ri wireless *
DTDeviceKitBase/DTDKRemoteDeviceConnection.h: _Bool _wireless;
DTDeviceKitBase/DTDKRemoteDeviceConnection.h:@property(readonly, getter=isWireless) _Bool wireless; // @synthesize wireless=_wireless;
DTDeviceKitBase/DTDKRemoteDeviceToken.h: DTDKRemoteDeviceConnection *_primaryWirelessConection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:+ (id)keyPathsForValuesAffectingHasWirelessConnection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:@property(retain, nonatomic) DTDKRemoteDeviceConnection *primaryWirelessConection; // @synthesize primaryWirelessConection=_primaryWirelessConection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)takeWirelessPowerAssertionWithName:(id)arg1 deatils:(id)arg2 andTimeout:(double)arg3;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)wirelessInstrumentsServer;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (void)disableWireless;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)enableWireless;
@neonichu
neonichu / shrugs.swift
Last active September 20, 2016 18:52
My new favourite Swift program.
#!/usr/bin/xcrun swift -suppress-warnings
infix operator ∖ {}
public func ∖ (a: Int, b: Int) -> Int {
return a + b
}
let ¯ = 1
let ツ = 2
@neonichu
neonichu / underscore.swift
Created May 8, 2015 16:46
Y U no compile?
#!/usr/bin/xcrun swift
let _ = 2
let x = _ / 2
println(x)
@neonichu
neonichu / podenv.rb
Last active March 1, 2020 07:13
A simple CocoaPods version manager.
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
def install_gem(name, version)
require 'rubygems/commands/install_command'
cmd = Gem::Commands::InstallCommand.new
cmd.handle_options [name, '--version', version]
begin
@neonichu
neonichu / int_value.m
Created April 22, 2015 21:31
Use a primitive integer as a value in a NSDictionary
int yolo = 23;
__unsafe_unretained id foo = (__bridge id)(void*)&yolo;
// CFDictionary allows not retaining values
typeof(@{}.mutableCopy) dict = (__bridge NSDictionary*)CFDictionaryCreateMutable(nil, 0, NULL, NULL);
dict[@"name"] = foo;
// We have to use CF APIs to avoid retaining the value here as well
__unsafe_unretained id foo2 = CFDictionaryGetValue((__bridge CFDictionaryRef)dict, @"name");
int heh = *(int *)(__bridge void *)foo2;