Skip to content

Instantly share code, notes, and snippets.

View hanssens's full-sized avatar

Juliën Hanssens hanssens

View GitHub Profile
@hanssens
hanssens / wordpress-menu.php
Created November 30, 2011 08:21
[PHP] Wordpress Dynamic Menu
#top-navigation ul ul a {
background:#333;
height:auto;
line-height:1em;
padding:10px;
width: 160px;
background-image: -moz-linear-gradient(100% 100% 90deg, #474747, #939393);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#939393), to(#474747));
}
@hanssens
hanssens / jquery.loadExternalContent.js
Created December 5, 2011 12:07
[jQuery] Load external content <div>
$('#result').load('ajax/test.html #container');
@hanssens
hanssens / StopWatch.cs
Created December 6, 2011 15:33
[C#] StopWatch
public enum StopWatchState
{
Started,
Stopped
}
public class StopWatch : IDisposable
{
public TimeSpan Started { get; private set; }
public TimeSpan Stopped { get; private set; }
@hanssens
hanssens / gist:1501644
Created December 20, 2011 13:57
[PHP] Set DateTime by Locale
// Sometimes the UTF-8 suffix is required (sigh)
setlocale(LC_ALL, 'nl_NL.UTF-8');
/* Expected Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
@hanssens
hanssens / SQL-To-DataTable.cs
Created January 16, 2012 09:19
[C#] SQL Query to Databable to CSV
// Simple example for
// 1.) Read a sql server query to datatable;
// 2.) Export it to .csv
class Program
{
static void Main(string[] args)
{
var connectionString = @"data source=bla bla bla";
var selectQuery = "select * from my-table;";
@hanssens
hanssens / NopCommerce.TopUsedManufacturers.sql
Created January 24, 2012 12:22
[SQL] Nopcommerce - Top used Manufacturers
-- Nopcommerce - Top used Manufacturers
-- Must remember to implement a storedproc or something ;)
select COUNT(*) as Aantal, ManufacturerId
from Product_Manufacturer_Mapping
group by ManufacturerId
order by Aantal desc;
@hanssens
hanssens / develop-tag.html
Created February 2, 2012 13:42
[HTML] Develop Tag (Overlay)
<!-- develop tag (single line) -->
<div id="develop-tag" style="position: absolute; top: 0; left: 0; z-index: 99;"><img src="http://tinyurl.com/86tauqv" /></div>
<!-- develop tag (multi-line) -->
<div id="develop-tag" style="position: absolute; top: 0; left: 0; z-index: 99;">
<img src="http://tinyurl.com/86tauqv" />
</div>
@hanssens
hanssens / DefaultController.cs
Created February 2, 2012 14:19
[C#] MVC3 Default Controller Actions
/// <summary>
/// Default MVC 3 Controller Actions
/// </summary>
public class ObjectController : Controller
{
// GET: /Object/
public ActionResult Index()
// GET: /Object/Details/5
public ActionResult Details(int id)
@hanssens
hanssens / Logger.cs
Created February 3, 2012 11:23
[C#] Simple Logger
namespace Hanssens.Tools
{
public enum LogTypes
{
/// <summary>
/// The default message type.
/// </summary>
Info,
Debug,
Error,
@hanssens
hanssens / RenderHash.cs
Created March 2, 2012 17:18
[C#] RenderHash() - String Extension for generating a (SHA1) hash
/// <summary>
/// Generates a (SHA1) hashed string, by using the passphrase as a poor man's salt.
/// </summary>
/// <param name="orderReference">(Optional) This reference is used for storing a (temporary) shipping order. You can decide for yourself which reference to use, but it needs to be unique. The reference is used for identifying the shipping order in the Paazl database.</param>
public static string RenderHash(this string value, string passPhrase)
{
// Append the passphrase to the value
value += passPhrase;
// Convert the string value to a byte array