Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
@danesparza
danesparza / gist:973923
Created May 16, 2011 04:02
Gravatar in C# - creating the hash
using System.Security.Cryptography;
/// Hashes an email with MD5. Suitable for use with Gravatar profile
/// image urls
public static string HashEmailForGravatar(string email)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
@joelmartinez
joelmartinez / GameOfLife.cs
Created September 5, 2011 03:24
Conway's Game Of Life in C#
using System;
using System.Threading.Tasks;
namespace Life
{
public class LifeSimulation
{
private bool[,] world;
private bool[,] nextGeneration;
private Task processTask;
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jboner
jboner / latency.txt
Last active May 24, 2024 16:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jculverwell
jculverwell / migration.sql
Created September 1, 2012 19:50
Migration from ASP.NET Membership to SimpleMembership
--This script attempts to migrate the users
--from the old ASP.Net Membership tables
--into the new SimpleMemberShip tables
--The SimpleMembsership uses more secure password hashing, as such the old password hashes won't
--work with the SimpleMembership tables.
--As far as I can tell you have two options
--1) Get your users to reset their passwords
--2) Update your web.config to force SimpleMembership to use the old SHA1 format. See more details
--here http://stackoverflow.com/questions/12236533/migrating-from-asp-net-membership-to-simplemembership-in-mvc4-rtm
@bradygaster-zz
bradygaster-zz / Configuration.cs
Created October 28, 2012 19:25
Code associated with a location API used to demonstrate EF Spatial and Windows Azure Web Sites
internal sealed class Configuration : DbMigrationsConfiguration<SpatialDemo.Models.SpatialDemoContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(SpatialDemo.Models.SpatialDemoContext context)
{
context.Locations.AddOrUpdate((x) => x.Name,
@tdreyno
tdreyno / airports.json
Created December 13, 2012 18:50
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
"woeid": "12512819",
@freeformz
freeformz / gist:4552031
Last active August 5, 2017 20:18
statvfs (cgo)
package main
// build +cgo
import (
"fmt"
"os"
"unsafe"
)
@davidfowl
davidfowl / hub.cs
Last active December 14, 2015 17:38
Future of filtering in SignalR
public class MyHub : Hub
{
public Task SendToQuery(string query, string value)
{
// Call the send to everybody that has the specified query string value
return Clients.Query(c => c.QueryString[query] == value).send();
}
}