Skip to content

Instantly share code, notes, and snippets.

@pparadis
pparadis / Sinatra.rb
Created January 25, 2013 02:00
Sinatra
require 'sinatra'
get '/' do
'FrenchCoding'
end
var x = function func(){
//rien, juste pour l'exemple
}
x.prototype.log = function() {
console.log("2");
}
var a = new x();
a.log(); //retourne "2"
async Task<int> AccessTheWebAsync()
{
HttpClient client = new HttpClient();
Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");
GrosseEtLongueTache();
string urlContents = await getStringTask;
return urlContents.Length;
}
var names = collection
.Where(item => item.Name == "Fred")
.OrderBy(item => item.Age)
.Select(item => item.Name)
var names = from item in collection
where item.Name == "Fred"
order by item.Age
select item.Name;
@pparadis
pparadis / gist:4152278
Created November 27, 2012 04:02
Array
array_elements = ['table', 'chair', 'floor']
array_elements.each do | element |
puts "#{element} est dans la liste!"
end
@pparadis
pparadis / gist:3977684
Created October 30, 2012 01:01
ASP.NET 301 Redirect
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "/");
@pparadis
pparadis / gist:3969393
Created October 28, 2012 18:39
captureVisibleTab
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.captureVisibleTab(tab.windowId, {"format": "png"}, function(img) {
window.open(img);
});
});
@pparadis
pparadis / gist:3935723
Created October 23, 2012 00:09
Fibonacci ForEach
foreach (var x in YieldTest.Fibonacci(10))
{
System.Console.WriteLine(x);
}
@pparadis
pparadis / gist:3935678
Created October 23, 2012 00:02
Fibonacci
public IEnumerable<int> Fibonacci(int x)
{
int prev = -1;
int next = 1;
for (int i = 0; i < x; i++)
{
int sum = prev + next;
prev = next;
next = sum;
yield return sum;