Skip to content

Instantly share code, notes, and snippets.

View tracend's full-sized avatar
🎯
Focusing

✌ Makis Tracend tracend

🎯
Focusing
View GitHub Profile
@tracend
tracend / gist:912308
Created April 10, 2011 12:40
DirectInput keyboard scan codes
/****************************************************************************
*
* DirectInput keyboard scan codes
*
****************************************************************************/
#define DIK_ESCAPE 0x01
#define DIK_1 0x02
#define DIK_2 0x03
#define DIK_3 0x04
#define DIK_4 0x05
@tracend
tracend / .handlebars.operators.md
Last active April 10, 2024 21:21
Handlebars relational operators #handlebars #helper #cc

Handlebars relational operators

This is a series of MATLAB style relational operators for Handlebars.

Operators

  • eq - equal to
  • ne - not equal to
  • lt - less than
  • gt - greater than
@tracend
tracend / common.loading.css
Last active February 21, 2024 11:59
CSS3 Loading Overlay
body.loading:after {
/* with no content, nothing is rendered */
content: "";
position: fixed;
/* element stretched to cover during rotation an aspect ratio up to 1/10 */
top: -500%;
left: -500%;
right: -500%;
bottom: -500%;
z-index: 9999;
// Unique ID generator, based on date
uniq_id = require('crypto').
createHash('md5').
update("" + (new Date()).getTime()).
digest("hex");
@tracend
tracend / passwords.php
Created May 10, 2011 05:52
PHP: Encryption / decryption of passwords
<?php
function encryptPassword($value){
if(!$value){return false;}
$text = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SECRET_KEY, $text, MCRYPT_MODE_ECB, $iv);
return trim(base64_encode($crypttext)); //encode for cookie
}
@tracend
tracend / SmoothLookAt.js
Created March 30, 2011 00:09
Unity3D: Camera script to smoothly look at any direction - Source: http://wiki.dreamsteep.com/Unity_tools
var target : Transform;
var damping = 6.0;
var smooth = true;
@script AddComponentMenu("Camera-Control/Smooth Look At")
function LateUpdate () {
if (target) {
if (smooth)
{
@tracend
tracend / stop_sql_injection.php
Created April 20, 2011 22:22
PHP: Prevent SQL Injection
$sql = safeInput("UPDATE table_name SET field_one='%s', field_two='%s' WHERE id='%s'", $input);
function safeInput($string, $args){
foreach( $input as $key => $value ){
// 'clean' the input
$args[$key] = mysql_real_escape_string($value);
}
// add the statement as the first element of the array
$args[0] = $string;
@tracend
tracend / uniqueCode.js
Created December 31, 2013 22:56
Unique Code: Generate short IDs based on UTC Based on the C# version: http://schroedman.wordpress.com/2012/01/19/short-unique-id-in-c-without-using-guid/
function uniqueCode(){
var characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var ticks = (new Date()).getTime().toString();
var code = "";
for (var i = 0; i < characters.length; i += 2) {
if ((i + 2) <= ticks.length) {
var number = parseInt(ticks.substr(i, 2));
if (number > characters.length - 1) {
var one = number.toString().substr(0, 1);
var two = number.toString().substr(1, 1);
@tracend
tracend / underscore.inArray.js
Last active May 26, 2020 13:25
_.inArray() #underscore #mixin #cc
_.mixin({
// - Checks if a string is in an Array
// Source: https://gist.github.com/tracend/570113fcb329aaf69bf0
inArray: function(value, array){
// if not an array just output false
return ( array instanceof Array ) ? (array.indexOf(value) > -1) : false;
}
});