Skip to content

Instantly share code, notes, and snippets.

@zyzo
zyzo / android-bitmap
Created Mar 24, 2014
Android snippet - displaying and playing around with Bitmap image
View android-bitmap
package com.dha.contagion;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
@zyzo
zyzo / android-imageswitcher
Created Apr 1, 2014
Android snippet - manipulating ImageSwitcher class
View android-imageswitcher
protected void onCreate(Bundle savedInstanceState) {
...
mImageSwitcher = (ImageSwitcher) findViewById(R.id.switcher1);
mImageSwitcher.setFactory(new ViewFactory() {
@Override
public View makeView() {
return new ImageView(GameActivity.this);
}
});
View date-sorting.js
/** Derivative work from date-de plug-in :
* https://github.com/DataTables/Plugins/blob/master/sorting/date-de.js
*
* date and time : dd[DATE_SP]mm[DATE_SP]yy HH[TIME_SP]mm[TIME_SP]ss
* date : dd[DATE_SP]mm[DATE_SP]yy
*
* @author zyzo
* @example
* "columnDefs": [
{type : 'datetime', targets : 3},
@zyzo
zyzo / casse-tête.pl
Last active Aug 29, 2015
casse-tete-prolog : calculer les methodes de poser des cercles avec les trous sur un disque
View casse-tête.pl
/* disque(Nom, Motif) - Modélisation des disques */
disque(a, [-1, 0, 0, 0, 0, 0]).
disque(b, [-1, -1, 0, 0, 0, 0]).
disque(c, [-1, 0, -1, 0, 0, 0]).
disque(d, [-1, 0, 0, -1, 0, 0]).
disque(e, [-1, -1, -1, 0, 0, 0]).
disque(f, [-1, -1, 0, -1, 0, 0]).
disque(g, [-1, 0, -1, 0, -1, 0]).
disque(h, [-1, -1, -1, -1, 0, 0]).
@zyzo
zyzo / remove-file-history-from-git
Last active Aug 29, 2015
Step to remove completely a file and its histories from git
View remove-file-history-from-git
1. Delete file from git repository
1. Download bfg.jar from http://rtyley.github.io/bfg-repo-cleaner/
2. mirror clone the project
$ git clone --mirror git://example.com/my-repo.git
3. Run
$ java -jar bfg.jar --delete-files fileToDelete my-repo.git
4. Update
$ cd my-repo.git
$ git reflog expire --expire=now --all && git gc --prune=now --aggressive
5. Finally, push it back up :
@zyzo
zyzo / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zyzo
zyzo / interpreter.ml
Created Dec 16, 2014
Interpreter of lambda expression
View interpreter.ml
open List;;
open Plf;;
open Plftypes;;
let primitives = ["succ" ; "plus" ; "moins" ; "fois" ; "div" ; "egal"];;
let rec present e l = match l with
[] -> false
| x::r when x=e-> true
| x::r -> present e r
@zyzo
zyzo / leCompteEstBon.pl
Created Dec 17, 2014
Programme solveur du jeu Le Compte Est Bon
View leCompteEstBon.pl
/**
* Programme solveur du jeu Le Compte Est Bon.
* Donnees : - Ensemble P de six nombres P = [P1, P2, P3, P4, P5, P6],
* chaque nombre tire aleatoirement parmi 1,2,3,4,5,7,8,9,10,25,50,75,100]
* - Nombre cible N
* Objectif : Trouver un ensemble d'oprations (+,-,*,// division entiere) utilisant
les nombres de P qui conduisent a N. Le tirage des nombres est sans remis
*/
@zyzo
zyzo / configure-gmail-as-relay-smtp
Created Dec 30, 2014
configure gmail as relay smtp using postfix
View configure-gmail-as-relay-smtp
Steps to configure this server to send mail via gmail relay
1. Download postfix and required packages
sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
2. Configure gmail as relay host : in /etc/postfix/main.cf
relayhost = [smtp.gmail.com]:587
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
@zyzo
zyzo / Exo2-XQuery.xql
Last active Aug 29, 2015
Exercice de MDSI (Modele de donnees et Systeme d'Info) - 4eme annee Info INSA de Toulouse
View Exo2-XQuery.xql
xquery version "3.0";
element Partie2 {
element FilmsQueJoueSigourneyWeaver {
for $x in doc("Films.xml")//film
where data($x//acteur) = "Sigourney Weaver"
return element titre {$x//titre}
},
element InfoRealisateursFilmAlien {
You can’t perform that action at this time.