Skip to content

Instantly share code, notes, and snippets.

Christian Hedin ciryon

Block or report user

Report or block ciryon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ciryon on github.
  • I am ciryon (https://keybase.io/ciryon) on keybase.
  • I have a public key ASDhUuEPIoguTlRZRA_KXtJWdqLW7jknzuklzlukIq0mYgo

To claim this, I am signing this object:

@ciryon
ciryon / VendRefactored.swift
Created Jan 3, 2016 — forked from eofster/VendRefactored.swift
Vending machine vend() function refactored
View VendRefactored.swift
func vend(itemNamed name: String) throws {
let item = try validatedItemNamed(name)
reduceDepositedCoinsBy(item.price)
removeFromInventory(item, name: name)
dispense(name)
}
private func validatedItemNamed(name: String) throws -> Item {
let item = try itemNamed(name)
try validate(item)
@ciryon
ciryon / TimeAgoInWords.swift
Created Aug 24, 2015
Time a go in words for swift
View TimeAgoInWords.swift
extension NSDate {
func timeAgoInWords() -> String {
let secondsDiff = self.timeIntervalSinceNow
if secondsDiff < 60 {
return "JUST_NOW".localized
}
if secondsDiff < 3600 {
let minutesAgo = secondsDiff / 60
return "X_MINS_AGO".localizedStringWithVariables(minutesAgo)
View weather.coffee
# Prep: npm install whatismyip geoip-lite openweathermap
# Usage: coffee weather.coffee hostname
# Provide hostname as argument and weather is looked up for that hostname.
# Skip argument and YOUR location is used (if found)
# Patched together one cold evening by Christian Hedin, github.com/ciryon
#
dns = require 'dns'
ip = require 'whatismyip'
geoip = require 'geoip-lite'
View gist:2125b921f756b1e222f7
on adding folder items to this_folder after receiving added_items
property movieExtList : {"mov", "mpg", "mp4"}
try
tell application "Finder"
--get the name of the folder
set the folder_name to the name of this_folder
View MHHistory.m
// interface file
@interface MHHistory : NSObject
{
NSMutableArray *_historyArray;
}
@property (nonatomic, retain) NSMutableArray *historyArray;
View gist:872452
<html>
<head>
<style>
div {left: 20px; top: 50px; width: 120px; height: 20px; border: thin solid black; overflow: hidden; text-overflow: ellipsis }
.ellipsis
{
vertical-align: text-bottom;
float: right;
View CSS to handle iPhone rotation
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<style type="text/css" media="screen">
/* portrait mode */
@media screen and (max-width: 320px) {
#rotateme {
background-color: #ff2900;
width: 100px;
height: 200px;
border: 2px solid #000;
@ciryon
ciryon / bug with $ajax
Created Jan 18, 2011
Då servern inte svarar går den ändå in i success-callbacken
View bug with $ajax
load_data_into_table:function (page_id, category_id, on_success) {
app.show_spinner();
var aWhiteWheel = new activityIndicator($('#WhiteWheel'));
aWhiteWheel.start();
var url_to_use = serverHost+"/items/"+category_id;
if (category_id==null) {
url_to_use = serverHost+"/items";
};
$.ajax({
@ciryon
ciryon / fix_for_itunes_connect_swedish
Created Nov 1, 2010
Fix for itunes_connect in Swedish iTunes Connect
View fix_for_itunes_connect_swedish
def initialize(input)
@data = Hash.new { |h,k| h[k] = { }}
input.each do |line|
line.chomp!
next if line =~ /^(Provider|$)/
tokens = line.split(/\t/)
country = tokens[12]
count = tokens[7].to_i
@data[country][:date] = Date.parse(tokens[9])
type = tokens[6]
You can’t perform that action at this time.