Skip to content

Instantly share code, notes, and snippets.

public Post GetMostRecentPost()
{
Post mostRecentPost;
using(var db = Mongo.Create("mongodb://localhost/BlogApp"))
{
var posts = db.GetCollection<Post>();
//create a LINQ queryable to search the DB.
var q = posts.AsQueryable();
@abolibibelot
abolibibelot / locloc.java
Created March 20, 2011 22:22
mapview in android
package mono.samples.googlemaps;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import java.util.List;
import android.graphics.Bitmap;
@abolibibelot
abolibibelot / GeoSample.cs
Created March 20, 2011 22:24
Scary interop in monodroid to make mapviews kinda work
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace GoogleMaps
@abolibibelot
abolibibelot / MapReceiver.java
Created March 21, 2011 13:00
A meager pass-through class for communication between .NET and Dalvik
package mono.samples.googlemaps;
import java.util.List;
public class MapReceiver{
static List<Object> Coords;
public static void setCoordinates(List<Object> coords){
Coords = coords;
[TestMethod]
public void RecordDispatchTest()
{
var ads = new FlushingQueue<RecordModel> {Threshold = 2000};
var noAds = new FlushingQueue<RecordModel> {Threshold = 2000};
var rootDir = Directory.GetCurrentDirectory();
ads.FilenameProvider = () => rootDir + "/ads_" + Guid.NewGuid() + "_ads.txt";
@abolibibelot
abolibibelot / dlfree.py
Last active December 11, 2015 21:58
requests API >= 0.13.6 mandates passing prefetch=False when accessing the raw response as a file like object... (see https://github.com/kennethreitz/requests/issues/825 )
import requests
import re
import os
import sys
def getFile( id ):
url = 'http://dl.free.fr/%s' % id
# get initial link
@abolibibelot
abolibibelot / gist:5404396
Last active December 16, 2015 08:18
Merging dictionarie
Boxes = compute_box_set(Lat,Lon,Res,Slice),
Results = [ GetFun(Box) || Box <- Boxes],
ResAcc = lists:foldl(fun(ElemDict,Acc)->
dict:merge(fun(_,V1,V2)-> lists:append(V1,V2) end,ElemDict,Acc)
end,
dict:new(),Results),
void Main()
{
var res = (from taz in new[]{0,1,2}
from pieds in Enumerable.Range(1,10 - taz)
from gifles in Enumerable.Range(1,10 - pieds - taz)
let productivite = gifles * 50 + pieds * 100 + taz * 200
let bugs = gifles * 2 + pieds * 5 + taz * 11
where bugs <= 50
select new []{taz,pieds,gifles,bugs,productivite})
.MaxOf(o => o[4]);
void Main()
{
var chrono = new Stopwatch();
chrono.Start();
Syntouze res = null;
for (var i=0; i < 1000; i++)
res = (from taz in new[]{0,1,2}
from pieds in Enumerable.Range(1,10 - taz)
from gifles in Enumerable.Range(1,10 - pieds - taz)
let touze = new Syntouze{Taz=taz,Pieds=pieds,Gifles=gifles}
4> A = integer_to_list(42).
"42"
5> [C+1 || C <- A].
"53"
6> [C+1000 || C <- A].
[1052,1050]