Skip to content

Instantly share code, notes, and snippets.

View JulienSansot's full-sized avatar

Julien Sansot JulienSansot

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace ConsoleApplication3
{
public class Program
{
foreach (string prop in props)
{
if (prop == "Count")
{
var countMethod = (typeof(Enumerable)).GetMethods().First(m => m.Name == "Count").MakeGenericMethod(type);
expr = Expression.Call(countMethod, expr);
break;
}
PropertyInfo pi = type.GetProperty(prop);
@JulienSansot
JulienSansot / Generic Repository
Created December 4, 2013 06:11
Entity Framework Generic Repository
public interface IRepository
{
IQueryable<T> Query<T>() where T : class;
T Add<T>(T entity) where T : class;
T Update<T>(T entity) where T : class;
void Delete<T>(T entity) where T : class;
}
public class Repository : IRepository
{
@JulienSansot
JulienSansot / gist:656c396fab947a462e4e
Created August 25, 2014 01:10
printing javascript object in the page
<div>
</div>
<script>
var o = {
test1 : 50,
test2 : 'Test',
test3: {
test4: 'test1',
test5: [1,2,3]
@JulienSansot
JulienSansot / gist:9fcdbd9aa2dc049fb310
Last active August 29, 2015 14:05
node.js global error handling + logging in LogEntries
var util = require('util');
var logentries = require('node-logentries');
var log = logentries.logger({
token:'11111111-2222-3333-4444-555555555555'
});
var d = require('domain').create();
d.on('error', function(err){
try {
@JulienSansot
JulienSansot / see_php_errors.php
Created February 5, 2015 10:11
see php errors
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
@JulienSansot
JulienSansot / index.html
Last active December 21, 2016 05:10
quick page with bootstrap and lodash
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
@JulienSansot
JulienSansot / asynctest_controller.rb
Last active January 16, 2016 00:08
async controller in rails with Thin, EventMachine, em-synchrony, em-http-request
class AsynctestController < ApplicationController
require "em-synchrony/em-http"
def test
EventMachine.synchrony do
http = EventMachine::HttpRequest.new("https://www.google.co.uk/").get
render :json => {result: http.response}
@JulienSansot
JulienSansot / table.js
Created March 4, 2015 06:17
dataTable order on an other column
$('#table').dataTable({
ajax: '/things',
columns:[
{data: 'col1', visible: false },
{data: 'col2', title:'col2', dataSort:'0'}
]
});
@JulienSansot
JulienSansot / script.sh
Created March 4, 2015 09:46
loop checking the http status code returned by the server. Every 0.5 seconds. Useful to check if there's no downtime while deploying a new version
while true; do curl -w %{http_code}:%{time_total} http://www.google.com/ -o /dev/null -s; printf "\n"; sleep 0.5; done