Skip to content

Instantly share code, notes, and snippets.

View andrekandore's full-sized avatar

アンドレカンドレ andrekandore

View GitHub Profile
@andrekandore
andrekandore / build-grub-osx.sh
Created March 17, 2019 10:57 — forked from emkay/build-grub-osx.sh
Build Grub on OSX
#!/bin/sh
set -e
# First we are going to make sure that you understand this is sort of experimental and we will be compiling stuff.
# by default CONTINUE will be false
CONTINUE=false
echo ""
echo "You are about to download, compile, and install stuff on your computer."
@andrekandore
andrekandore / keypaths.playground
Created June 9, 2018 00:12 — forked from desugaring/keypaths.playground
Two-way binding in iOS using KVO
//: Playground - noun: a place where people can play
import UIKit
/* Scroll to the bottom for examples */
typealias WritableObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: WritableKeyPath<O, V>)
typealias ReadOnlyObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: KeyPath<O, V>)
func bind<O: NSObject, O2: NSObject, V: Equatable>(source: ReadOnlyObjectKeyPath<O, V>, to target: WritableObjectKeyPath<O2, V>) -> NSKeyValueObservation?
@andrekandore
andrekandore / Actor State.swift
Last active August 18, 2017 05:34
Just an idea!
actor Downloader {
let mainActor : TheMainActor
var theList : [URL] = []
init(mainActor: TheMainActor) { self.mainActor = mainActor }
actor case .initialized, .ready {
actor func setList(list:[String]) -> self.ready? //can only call this from these 2 (initialized and ready) states
}
actor case .ready {
@andrekandore
andrekandore / Country.swift
Created February 19, 2017 12:55 — forked from kharrison/Country.swift
Swift Hash Functions
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@andrekandore
andrekandore / index.html
Created July 5, 2013 10:47
A CodePen by アンドレカンドレ.
<html>
<div class="container">
<div class='picture_container' id='picture1'>
<img class='picture' src="http://ecx.images-amazon.com/images/I/31TmE1so1SL.jpg" alt="" />
</div>
<div class='picture_container' id='picture2'>
<img class='picture' src="http://ecx.images-amazon.com/images/I/615bt5a8zEL.jpg" alt="" />
</div>
<div class='picture_container' id='picture3'>
<img class='picture' src="http://ecx.images-amazon.com/images/I/41si2LNmptL.jpg" alt="" />
@andrekandore
andrekandore / gist:3140554
Created July 19, 2012 03:27 — forked from RiANOl/gist:1077760
AES128, AES256 encrypt/decrypt in Ruby
require "openssl"
require "digest"
def aes128_encrypt(key, data)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.update(data) + aes.final
end
@andrekandore
andrekandore / UIDeviceHardware.h
Created June 28, 2012 12:14 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@andrekandore
andrekandore / BNRDiggyDict.h
Created June 5, 2012 02:54 — forked from markd2/BNRDiggyDict.h
Objective-C Literals, part 2 support files.
#import <Foundation/Foundation.h>
@interface BNRDiggyDict : NSObject
// React to object indexing. Would be nice to have a @protocol for this
- (id) objectForKeyedSubscript: (id) key;
- (void) setObject: (id) thing forKeyedSubscript: (id<NSCopying>) key;
// And for fun, it also can react to scalar indexing.
// Returns the N'th key of the top-level collection.