Skip to content

Instantly share code, notes, and snippets.

@PifyZ
PifyZ / control-mouse.coffee
Last active August 29, 2015 13:55
Contrôle des évènements de la souris
class Mouse
constructor: (el) ->
@el = el
@x = 0
@y = 0
@click = null
@mtime = 0
@loose = null
document.addEventListener('mousedown', @onmousedown)
@PifyZ
PifyZ / px.js
Last active August 29, 2015 13:55
Px.js
/*#--------------------------#*/
/*# CanvasRenderingContext2D #*/
/*#--------------------------#*/
/** TODO : Name & Code & Test
* Récupère le bout d'une image à afficher
*
* @param img {Image} Image à couper
* @param width {int} Taille en largeur à couper
* @param height {int} Taille en hauteur à couper
* @param x {number} Position x à laquelle l'image sera affichée
(function() {
function object_merge(obj1, obj2){
var obj3 = {};
for (var attrname in obj1)
obj3[attrname] = obj1[attrname];
for (var attrname in obj2)
obj3[attrname] = obj2[attrname];
(function() {
function bar_chart(el, datas) {
// Récupération de la zone de dessin
var can = document.getElementById(el);
var ctx = can.getContext('2d');
// Récupération de la valeur maximale
var max_of_array = 0;
for (var i = 0, nb_datas = datas.length ; i < nb_datas ; i++) {
if (datas[i][0] > max_of_array)
@PifyZ
PifyZ / baseClass.js
Created February 24, 2014 15:19 — forked from dalgard/Class.js
// The base constructor (can be left empty, but a nice boilerplate might look like this)
function Class(properties) {
if (properties) {
// Add properties to the instance
Object.getOwnPropertyNames(properties).forEach(function (property_name) {
var descriptor = Object.getOwnPropertyDescriptor(properties, property_name);
Object.defineProperty(this, property_name, descriptor);
}, this);
}
}
@PifyZ
PifyZ / learn.lua
Created February 26, 2014 08:57 — forked from tylerneylon/learn.lua
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@PifyZ
PifyZ / index.html
Created April 28, 2014 16:48
control_keyboard.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Contrôle du clavier</title>
<style>
html, body {
background-color: rgb(255, 255, 255);
}
@PifyZ
PifyZ / client.c
Last active August 29, 2015 14:04
Client/Serveur C
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
#define SERVER_ADDR "192.168.0.50"
// #define SERVER_ADDR "127.0.0.1"
#define SERVER_PORT 9002
int main (int argc, char *argv[]) {
char buff[256];
@PifyZ
PifyZ / pom.c
Created August 3, 2014 19:44
Plus ou moins
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main (int argc, char *argv[]) {
srand(time(NULL));
int nb_rand = rand() % 100;
int saisie = -1;
int nb_essais = 0;
@PifyZ
PifyZ / pom.bm
Last active August 29, 2015 14:05
Plus ou moins (Bootmonkey)
use stdio as io
use math
Num main(List<Str> args) {
Num nb_rand = math.rand(0, 100)
Num saisie = -1
Num nb_essais = 0
do {
saisie = io.ask("Essai n#{nb_essais + 1} = ").to_num()