Skip to content

Instantly share code, notes, and snippets.

View tvdsluijs's full-sized avatar

Theo van der Sluijs tvdsluijs

View GitHub Profile
@tvdsluijs
tvdsluijs / read_mem_flex.xmln
Created August 8, 2012 05:41
Read out system memory using Adobe Flex
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" width="659" height="352"
creationComplete="SySMem();">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
@tvdsluijs
tvdsluijs / FLEX_AS3_Password_gen.xlmn
Created August 8, 2012 05:44
Flex AS3 Password Creator / Generator
public function createpw(strHash:String = 'abchefghjkmnpqrstuvwxyz0123456789',lnHash:Number = 5):String
{
var i:Number = 0;
var hash:String = "";
var nLenght:Number = strHash.length;
while (i <= lnHash)
{
var num:Number = Math.round(Math.random()*nLenght);
hash += strHash.charAt(num);
i++;
@tvdsluijs
tvdsluijs / gist:3663508
Created September 7, 2012 05:40
Flex Password match check
<validator:StringMatchValidator id="passwordMatchValidator"
source="{password2}"
property="text"
matches="{password1.text}" />
//And just add this class to your project for the actual checking of the password match.
UPDATE jos_users SET `password` = CONCAT('%', CONCAT_WS(':', SHA2(CONCAT( UNIX_TIMESTAMP(`registerDate`) ,`password`),512),UNIX_TIMESTAMP(`registerDate`) ));
public function verifyPassword($passwd){
if(substr($this->password, 0, 1) == '#'){
$saved_pw = explode(':', substr($this->password, 1) );
$salt = $saved_pw[1];
$data = $salt.md5($passwd);
$givenPasswd = hash('sha512', $data); //oude manier controle!
if($givenPasswd === $saved_pw[0]){
//okay, sla ww op als sha512 !
$salt = generateSalt();
@tvdsluijs
tvdsluijs / gist:e6e8e9219c03d86f9eed
Created July 6, 2014 12:00
FLATTR Button in Ghost Theme
<!-- static flattr button -->
<a href="https://flattr.com/submit/auto?user_id=YOURFLATTRUSERNAME&url={{url absolute="true"}}&title={{encode title}}&description={{excerpt}}&language=nl_NL&tags={{tags autolink="false" separator=","}}&hidden=0&category=text">
<img src="https://flattr.com/_img/icons/flattr_logo_16.png" alt="Flattr Button"/>
</a>
<!-- end static flattr button -->
@tvdsluijs
tvdsluijs / simple_mongodb_get_example
Created October 12, 2014 14:57
Get data from MongoDB example
$mongo_host = 'mongodb://10.10.10.10/'; //vul hier jou ip adres in van je MongoDB omgeving
$m = new MongoClient($mongo_host);
$db = $m->blog; //maak connectie met database
$collection = $db->visits; // maak connectie met de tabel / collection
//je kan nu bijvoorbeeld al alle records tellen met
$nr = $collection->count();
echo "<p>aantal records in db : " . $nr . "</p>";
@tvdsluijs
tvdsluijs / gist:4dfb175a33b7913a750c
Last active August 29, 2015 14:13
Mongodb php aggregation $match usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category
$ops = array(
array(
'$match' => array("category" => 'socks')
)
@tvdsluijs
tvdsluijs / gist:757c55049bfecfec9971
Created January 9, 2015 18:59
Mongodb php aggregation $match $and usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category and brand
$ops = array(
array(
'$match' =>
array('$and' =>
@tvdsluijs
tvdsluijs / gist:fc0bb40ee0fe0805df8d
Created January 9, 2015 19:01
Mongodb php aggregation $match $or usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category = shoes or brand = nike
$ops = array(
array(
'$match' =>
array('$or' =>