Skip to content

Instantly share code, notes, and snippets.

@pparadis
pparadis / gist:3200680
Created July 29, 2012 18:06
Zip - Suppression
using (ZipArchive archive = ZipFile.Open(@"c:\frenchcoding\start.zip", ZipArchiveMode.Update))
{
archive
.GetEntry("test_compress2.txt")
.Delete();
archive
.GetEntry("test_compress3.txt")
.Delete();
}
@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;
@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: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:3977684
Created October 30, 2012 01:01
ASP.NET 301 Redirect
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "/");
@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
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 x = function func(){
//rien, juste pour l'exemple
}
x.prototype.log = function() {
console.log("2");
}
var a = new x();
a.log(); //retourne "2"
@pparadis
pparadis / Sinatra.rb
Created January 25, 2013 02:00
Sinatra
require 'sinatra'
get '/' do
'FrenchCoding'
end
require 'sinatra'
require 'base64'
require 'haml'
require 'securerandom'
set :static, true
set :public_folder, '/uploads'
get '/' do
haml :index