Skip to content

Instantly share code, notes, and snippets.

View jesperbjensen's full-sized avatar

Jesper Blad Jensen jesperbjensen

View GitHub Profile
@jesperbjensen
jesperbjensen / CommaSeperate.vb
Created April 5, 2011 06:44
A nice extension method that lets you comma seperate anything
<Extension()> _
Public Function CommaSeperate(Of T)(ByVal lstList As IEnumerable(Of T), ByVal delFunction As Func(Of T, String), ByVal strDelimiter As String) As String
Dim builder As New StringBuilder
For Each item As T In lstList
If delFunction IsNot Nothing Then
builder.Append(delFunction(item) & strDelimiter)
Else
builder.Append(item.ToString() & strDelimiter)
End If
Next
@jesperbjensen
jesperbjensen / FillWith.vb
Created April 5, 2011 06:46
A nice extension method that maps properties from one type to another
<Extension()> _
Public Sub FillWith(ByVal destination As Object, ByVal source As Object, ByVal ParamArray ignoredProps() As String)
Dim sourceType = source.GetType()
Dim props As New Dictionary(Of String, String)
For Each prop As String In ignoredProps
props.Add(prop, prop)
Next
For Each objProperty In destination.GetType().GetProperties()
@jesperbjensen
jesperbjensen / gist:939402
Created April 24, 2011 08:22
A little TextMate command for linking the current project up to Pow
# Links the current project to Pow: http://pow.cx
cd ~/.pow
ln -s $TM_PROJECT_DIRECTORY
echo "<p><strong>Done</strong></p>"
@jesperbjensen
jesperbjensen / twitrotator.html
Created April 28, 2011 15:46
Simple tweet rotator
<!DOCTYPE html>
<html>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js">
</script>
<script type="text/javascript" charset="utf-8">
var query = 'javascript';
$(function() {
$.getJSON("http://search.twitter.com/search.json?callback=?&q=" + query,
Using Vim settings from https://github.com/carlhuda/janus
:ls List open buffers
Ctrl+w c Closes the current window
o Begin a new line below the current one
:/searchterm Searches for the search word. Use n and N to move back
and forth
:map KEY COMMAND Creates a new command. Use <Leader> to choose the leader
key and <Enter> to execute it, for exsample.
H or M or L Moves to the first, middle or last line on screen.
@jesperbjensen
jesperbjensen / terminal.txt
Created August 10, 2011 10:44
Terminal Cheatcheet
tail -f [filename]
- shows the last lines of a file. The -f options makes it stay open, reload the file
rm -R [folder]
- removes a folder and it's content
@jesperbjensen
jesperbjensen / checkboxlist.html
Created September 15, 2011 14:50
A little code-snippet that lets you make a todo-list with little effort
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
ul { list-style: none; margin: 0; padding: 0;}
input[type=text] { border: 0px; width: 600px;}
li[data-indent='1'] { padding-left: 20px; }
li[data-indent='2'] { margin-left: 40px; }
li[data-indent='3'] { margin-left: 60px; }
@jesperbjensen
jesperbjensen / simpleLocalStorage.js
Created October 30, 2011 07:20
Simple local storage
localStorage.setItem("todo","My value")
var value = localStorage.getItem("todo")
alert(value)
@jesperbjensen
jesperbjensen / complexLocalStorage.js
Created October 30, 2011 07:20
Complex localStorage
var woldsMostAdvancedObject = {name: "Awsome"};
localStorage.setItem("todo",JSON.stringify(woldsMostAdvancedObject))
var value = JSON.Parse(localStorage.getItem("todo"))
alert(value.name)
@jesperbjensen
jesperbjensen / jquery_radiobuttons.js
Created May 2, 2012 06:32
The right way to check to get the selected radio button
// Wrong
var selected_value = $(".SelectedDelivery[checked=checked]").val()
// Right
var selected_value = $(".SelectedDelivery:checked").val()