Skip to content

Instantly share code, notes, and snippets.

View kballenegger's full-sized avatar

Kenneth Ballenegger kballenegger

View GitHub Profile
//
// File.c
//
//
// Created by Kenneth Ballenegger on 1/13/14.
//
//
#include <stdlib.h>
#include <stdio.h>
@kballenegger
kballenegger / FieldCreation.m
Last active December 31, 2015 16:38
Custom window problem
{
NSView *emailFieldContainer = [[NSView alloc] initWithFrame:NSMakeRect(80.0/2, 150.0/2, 650.0/2, 60.0/2)];
self->emailField = [[NSTextField alloc] initWithFrame:NSMakeRect(10.0/2, 10.0/2, 670.0/2, 40.0/2)];
self->emailField.stringValue = @"[email protected]";
[self->emailField setFont:boldFont];
[self->emailField setEditable:YES];
self->emailField.drawsBackground = NO;
[self->emailField setBezeled:NO];
self->emailField.textColor = [NSColor colorWithCalibratedRed:0.872 green:0.197 blue:0.228 alpha:1.000];
[self->emailField setWantsLayer:YES];
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<title>My Photo Page</title>
</head>
<body>
<table>
<thead>
<tr>
<html>
<head>
<title>Box Pricing</title>
<style>
td:nth-child(2) {
border-left:1px solid black;
}
td {
padding: 5px;
}
<!DOCTYPE html>
<html>
<head>
<title>Shannon Chang</title>
</head>
<body>
<img src=https://sphotos-b-lax.xx.fbcdn.net/hphotos-ash3/543436_10201924198617443_1291536366_n.jpg>
<p style="color:pink;font-size:26px"> About me: 22 year old female from Plano, Texas</p>
<ul style="font-family:Courier">
<li><strong>Interests:</strong> working, learning, playing, shopping, cooking, wine-tasting, gardening, and now CODING!</li>
@kballenegger
kballenegger / milene.rb
Created September 2, 2013 16:25
Fetching active campaigns by iTunes ID, using Kongo :).
# configure Kongo :)
Kongo::Collection.add_extension(:apps, Module.new do
def find_by_itunes_id(id)
find_many(itunes: id, live_notified: true)
end
self; end)
Apps = Kongo::Collection.new(:apps)
@kballenegger
kballenegger / modernizer.rb
Created August 22, 2013 22:29
This is what the DSL might look like.
Modernizer.new do
request_version { @env[...] }
first do
add 'hello' { 'hardcoded' }
end
modernize '1.2.1' do
add 'foo' { "#{@body['hello']}-bar" }
@kballenegger
kballenegger / cb_pbkdf2.c
Created August 19, 2013 19:20
PHP C modules for cb-pbkdf2.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_cb_pbkdf2.h"
#include <string.h>
#include "cb-pbkdf2.h"
@kballenegger
kballenegger / euler-31.rb
Created August 15, 2013 08:07
Project Euler, problem #31.
Cs = [1, 2, 5, 10, 20, 50, 100, 200]
def left(n, s)
Cs.select do |c|
c <= s
end.map do |c|
x = n-c
x > 1 ? left(x, c) : (x < 0 ? 0 : 1)
end.reduce(&:+)
end
@kballenegger
kballenegger / palindromes.rb
Created August 8, 2013 21:31
An algorithm to find all / the largest palindrome in a string.
string = '111sjhfb1234321asdjkhbfhhjjhhkik'
long_palindromes = []
(0..string.length-1).each do |i|
# xyx
xyx0 = i < 1 ? nil : string[i-1]
xyx1 = string[i]
xyx2 = string[i+1]
# xx