Skip to content

Instantly share code, notes, and snippets.

View Prinzhorn's full-sized avatar
🌚
Existing

Alexander Prinzhorn Prinzhorn

🌚
Existing
View GitHub Profile
@Prinzhorn
Prinzhorn / MySQL with .NET
Created December 20, 2011 22:46
All you basically need to use MySQL with .NET
using (MySqlDataReader reader = MySqlHelper.ExecuteReader(
"CONNECTION STRING",
"SELECT * FROM my_table WHERE foo=?bar;",
new MySqlParameter("?bar", 1337)/*, more params if needed */)
{
if(!reader.hasRows)
{
//No data
return;
@Prinzhorn
Prinzhorn / live-sample.js
Created December 28, 2011 16:24
jQuery-inlog samples
$('#about').siblings('h1').add('h2').css('color', '#09f').end().css('text-transform', 'uppercase');
@Prinzhorn
Prinzhorn / dabblet.css
Created January 25, 2012 13:30
Search form with fading search button
/**
* Search form with fading search button
* https://github.com/Prinzhorn
*/
.search {
border:1px solid #444;
display:inline-block;
}
@Prinzhorn
Prinzhorn / js.js
Created January 26, 2012 22:55
Use jQuery.animate to animate over multiple elements
;(function($) {
$.fn.popIn = function(dur) {
var $all = this;
$('<b>').animate({
foobar: $all.length
}, {
easing: 'easeInOutBounce',
duration: dur,
@Prinzhorn
Prinzhorn / example.js
Created February 27, 2012 18:52
Async forEach
/*
Iterate over all elements and do some async work on each element, but ensure they all get worked on in order
*/
var arr = [1, 2, 3];
asyncForEach(arr, function(next, element) {
console.log(element);
//Simulate async db call
setTimeout(next, 1000);
@Prinzhorn
Prinzhorn / switch.js
Created March 28, 2012 15:56
regex fall-throughs using a switch(true), inspired by @AvianFlu
substack : ~ $ node switch.js bleep blah
blah
substack : ~ $ node switch.js for the lose
lose
substack : ~ $ node switch.js for the win
win
substack : ~ $ node switch.js for the fail
fail
substack : ~ $
@Prinzhorn
Prinzhorn / wooot.js
Created April 2, 2012 16:35
Revising JavaScript's switch case
//This is part of a easing function I wrote
function(p, a) {
switch(true) {
case (p <= .5083):
a = 3; break;
case (p <= .8489):
a = 9; break;
case (p <= .96208):
a = 27; break;
case (p <= .99981):
@Prinzhorn
Prinzhorn / LICENSE.txt
Created May 7, 2012 15:55 — forked from 140bytes/LICENSE.txt
compress hex color string
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 Alexander Prinzhorn (@Prinzhorn) https://github.com/Prinzhorn
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Prinzhorn
Prinzhorn / example.js
Created May 24, 2012 16:06
Sort an array and keep track of all permutations in second array
//Sorts arr and syncs assArr simultaneously
var associatedSort = (function() {
var comparator = function(a, b) {
if(a[0] < b[0]) {
return -1;
}
if(a[0] > b[0]) {
return 1;
}
@Prinzhorn
Prinzhorn / bacon.md
Created September 19, 2012 08:24
Requirements for a MV* framework for small projects

I just want this a bit cleaner than using plain jQuery.

  • Dynamic view updates like Knockout/o_O
  • With the template syntax of Angular JS (this data-bind="text: bacon" is ridiculous)
  • Models with remote connection. E.g. I want to have a User object with CRUD connection to the server (Angular seems to have this with $resource, but documentation is outdated and I can't get it to work)

I don't need routing. I just want to have clean underlying data connected to the server which updates the view.

Maybe someone can recommend one or maybe two frameworks which solve this. One for the object stuff and another which can handle these objects and updates the view.