Skip to content

Instantly share code, notes, and snippets.

View andheiberg's full-sized avatar

Andreas Heiberg andheiberg

View GitHub Profile
@andheiberg
andheiberg / baseConverter.js
Last active June 17, 2018 13:33 — forked from faisalman/baseConverter.js
Convert From/To Binary/Decimal/Hexadecimal in JavaScript
/**
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* https://gist.github.com/faisalman
* https://gist.github.com/AndreasHeiberg
*
* Copyright 2012-2015, Faisalman <fyzlman@gmail.com>
* Licensed under The MIT License
* http://www.opensource.org/licenses/mit-license
*/
@andheiberg
andheiberg / import.py
Created July 16, 2015 18:59
Elasticsearch Tutorial
import requests
from elasticsearch import Elasticsearch
es = Elasticsearch()
# Return a response of the top 100 IAMA Reddit posts of all time
response = requests.get("http://api.reddit.com/r/iama/top/?t=all&limit=100",
headers={"User-Agent":"TrackMaven"})
fields = ['title', 'selftext', 'author', 'score',
var angles = angular.module("angles", []);
angles.chart = function (type) {
return {
restrict: "A",
scope: {
data: "=",
options: "=",
id: "@",
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Andheiberg\\Auth\\InvalidPasswordException' => $vendorDir . '/andheiberg/auth/src/Andheiberg/Auth/Exceptions.php',
'Andheiberg\\Auth\\InvalidTokenException' => $vendorDir . '/andheiberg/auth/src/Andheiberg/Auth/Exceptions.php',
@andheiberg
andheiberg / main.js
Last active December 22, 2015 13:28
Form validation with jQuery (and twitter bootstrap) http://testandheiberg.tumblr.com/post/60573208864/form-validation-with-jquery
jQuery.validator.setDefaults({
errorPlacement: function(error, element) {
// hide any previous help... this could be "not visible to others"
$(element).closest('.controls').find('.help-inline').addClass('hidden');
// if the input has a prepend or append element, put the validation msg after the parent div
if ($(element).parent().hasClass('input-prepend') || $(element).parent().hasClass('input-append')) {
error.insertAfter($(element).parent());
// else just place the validation message immediatly after the input
}
@andheiberg
andheiberg / File.php
Created August 25, 2013 19:13
Server side part of FineUploader
<?php namespace Models;
use \AWS;
class File extends BaseModel {
/**
* The database table used by the model.
*
* @var string
@andheiberg
andheiberg / index.html
Created July 9, 2012 20:48
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Logo &middot; CodePen</title>
<!--
Copyright (c) 2012 dylnhdsn, http://codepen.io/dylnhdsn
Permission is hereby granted, free of charge, to any person obtaining
@andheiberg
andheiberg / Transcode_video_to_apple_tv_and_add_it_to_itunes.sh
Created October 7, 2011 15:06
Transcode video to apple tv and add it to itunes
#!/bin/bash
#transcode.sh
#By Don Southard aka @binaryghost
#
#[UPDATE 6/01/2011 08:01:15PM]
#Idea and initialcode for Alfred progress bar by Andreas Heiberg
#Completly rewritten code by Don Southard
#
#[UPDATE 6/02/2011 08:58:09PM]
#Support for queueing, added information about queue status and ETA'S and the move the old file to trash feature