Skip to content

Instantly share code, notes, and snippets.


Michael Koukoullis kouky

View GitHub Profile
premek /
Last active May 8, 2022
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
gwengrid / TypeErasure.swift
Last active Sep 12, 2018
Example of type erasure with Pokemon
View TypeErasure.swift
class Thunder { }
class Fire { }
protocol Pokemon {
typealias PokemonType
func attack(move:PokemonType)
struct Pikachu: Pokemon {
typealias PokemonType = Thunder
View SKTexture gradient extension
- Create a linear gradient texture for a SKShapeNode and SKSpriteNode
- UIColor from hex value
- Get (n)th character of a string
- Convert string to float
Based on Extensions.swift by Craig Grummit (
Swift 2 Compatability by Ray Hughes (
rwarbelow / running_app_in_production_locally.markdown
Created Nov 11, 2015
How to Run a Rails App in Production Locally
View running_app_in_production_locally.markdown
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

nsforge / Warnings.xcconfig
Created Feb 26, 2015
Standard Xcode Warnings (for use in .xcconfig files)
View Warnings.xcconfig
// Apple LLVM - Warnings - All languages
kristopherjohnson / NSData_hexadecimalString.swift
Last active Jul 14, 2018
Convert NSData bytes to hexadecimal string
View NSData_hexadecimalString.swift
import Foundation
extension NSData {
/// Return hexadecimal string representation of NSData bytes
public var hexadecimalString: NSString {
var bytes = [UInt8](count: length, repeatedValue: 0)
getBytes(&bytes, length: length)
nsforge / gist:8949790
Created Feb 12, 2014
Demonstration of uint64 accuracy bug in NSJSONSerialization
View gist:8949790
NSString *jsonString = @"{\"myNumber\":1029742590268606522}";
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:NULL];
NSLog(@"jsonDict: %@", jsonDict);
uint64_t myNumber = [jsonDict[@"myNumber"] unsignedLongLongValue];
NSLog(@"myNumber: %llu", myNumber);
awesome / ruby-multi-line-string-without-newlines-AND-ruby-multi-line-string-without-concatenation.rb
Created Nov 21, 2013
Ruby Multi-line String without Newlines —AND— Ruby Multi-line String without Concatenation
View ruby-multi-line-string-without-newlines-AND-ruby-multi-line-string-without-concatenation.rb
# by SoAwesomeMan
str =<<-EOS.gsub(/^[\s\t]*|[\s\t]*\n/, '') # no space "\s" for new line "\n"; kill tabs too
select awesome, awesome, awesome, awesome, awesome, awesome,
from rad, rad, rad, rad, rad, rad, rad, rad, rad, rad, rad,
where cool cool cool cool cool cool cool cool cool cool cool'
# => "select awesome, awesome, awesome, awesome, awesome, awesome,from rad, rad, rad, rad, rad, rad, rad, rad, rad, rad, rad,where cool cool cool cool cool cool cool cool cool cool cool'"
str =<<-EOS.gsub(/^[\s\t]*/, '').gsub(/[\s\t]*\n/, ' ').strip # yes space "\s" for new line "\n"; kill tabs too
warnergodfrey / gist:7512051
Last active Sep 21, 2018
Access the ATO Business Portal using AusKey Mac OS X Mountain Lion
View gist:7512051
  • Install the latest JRE from Oracle
  • In the Java Control Panel, go to the Security tab and make sure 'Enable Java Content' is checked
  • Open Safari
  • Go to the ATO Business portal site
  • Click Login
  • A dialog will apear asking you 'Do you want to trust the website “” to use the “Java” plug-in?'
  • Click 'Trust'
  • Now you will be asked 'Do you want to run this application?'
  • Click 'Run'
  • Another dialog will appear asking you to 'Allow access to the following application from this website?'
aras-p / preprocessor_fun.h
Last active Dec 7, 2022
Things to commit just before leaving your job
View preprocessor_fun.h
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,