Skip to content

Instantly share code, notes, and snippets.

@bojanbjelic
bojanbjelic / ToStringViaReflection.cs
Last active December 29, 2015 17:39
generic ToString method to show properties and values using Reflection
public override string ToString()
{
var propertiesInfo =
GetType().GetProperties().Where(p => Attribute.IsDefined(p, typeof (DataMemberAttribute)));
StringBuilder str = new StringBuilder();
foreach (var propertyInfo in propertiesInfo)
{
if (str.Length > 0)
str.Append(", ");
@bojanbjelic
bojanbjelic / gist:6955563
Created October 12, 2013 22:18
reverse unordered list
Array.reverse.call(null, $('.rightColumn > ul:nth-child(1) li'))
@bojanbjelic
bojanbjelic / htmlEncode.js
Created July 28, 2013 23:03
JavaScript HTML encode
document.createElement('b').appendChild(document.createTextNode('&<>')).parentNode.innerHTML
@bojanbjelic
bojanbjelic / csv.sql
Created May 29, 2013 09:51
sql server csv
SELECT distinct
SUBSTRING((SELECT ',' + CAST(countryId as VARCHAR)
FROM countries_regions where countries_regions.regionId = regions.id
FOR XML PATH('')), 2, 20000) AS CSV, regions.id
FROM countries_regions
inner join regions ON countries_regions.regionId = regions.id
// Create a symmetrical diamond shaped (sideways square) "snowflake".
// This can be rotated 45° to make a square.
// Create 1/8th of the shape and reflect that for the remaining 7/8ths.
// Make it a repeatable function with a parameter for the center XY.
// New pattern generated on key press.
// Animated GIF generated and saved on form unload.
// ToDo: Store as class? Then it would be copyable...
// Keys:
// Create a symmetrical diamond shaped (sideways square) snowflake.
// Create 1/8th of the shape and reflect that for the remaining 7/8ths.
// Make it a repeatable function with a parameter for the center XY.
// New pattern generated on key press.
// Animated GIF generated and saved on form unload.
// ToDo: Store as class? Then it would be copyable.
// Save as animated GIF
// Save as animated GIF
// Requires gifAnimation Processing Library
// http://www.extrapixel.ch/processing/gifAnimation/
import gifAnimation.*;
GifMaker gifExport;
boolean saveToGif = false;
// The time between GIF frames
int frameDelay = 60;
// Save as animated GIF
// Requires gifAnimation Processing Library
// http://www.extrapixel.ch/processing/gifAnimation/
import gifAnimation.*;
GifMaker gifExport;
boolean saveToGif = false;
// The time between GIF frames
int frameDelay = 60;
// Save as animated GIF
// Requires gifAnimation Processing Library
// http://www.extrapixel.ch/processing/gifAnimation/
import gifAnimation.*;
GifMaker gifExport;
boolean saveToGif = true;
// The time between GIF frames
int frameDelay = 50;
// Save as animated GIF
// Requires gifAnimation Processing Library
// http://www.extrapixel.ch/processing/gifAnimation/
import gifAnimation.*;
GifMaker gifExport;
boolean saveToGif = true;
// The time between GIF frames
int frameDelay = 60;