Skip to content

Instantly share code, notes, and snippets.

View levonlee's full-sized avatar
🎯
Focusing

misterlcanada levonlee

🎯
Focusing
View GitHub Profile
@levonlee
levonlee / PHP Test Website Connection
Created July 16, 2014 14:25
PHP Test Website Connection
$loop = 20; // Number of times to connect to website
$url = "http://www.yoursite.com/";
$start = microtime(true);
for ($i=1; $i < $loop; $i++) {
$lstart = microtime(true);
$f = fopen($url, 'r', 0);
$meta_data =stream_get_meta_data($f)['wrapper_data'][0];
@levonlee
levonlee / Edit Scope Variable inside ng-repeat.md
Last active August 29, 2015 14:23
Edit scope variable in ng-repeat

Edit scope variable in ng-repeat

Use ng-attr-your-attribute to conditionally add or remove an attribute in HTML element. AngularJS 1.3 above

@levonlee
levonlee / AngularJS ngOptions.md
Last active August 29, 2015 14:24
AngularJS ngOptions

Try out ng-options inside ``

@levonlee
levonlee / Condition_in_Array_Definition.php
Last active August 29, 2015 14:24
Conditionally add key and value inside array();
<?php
$condition = true;
$arr = array(
'a' => 'abc',
($condition ? 'b' : '') => ($condition ? '123' : ''),
($condition ? 'c' : '') => ($condition ? 'xyz' : ''),
);
$arr = array_filter($arr);
<?php
$condition = true;
$arr = array(
'a' => 'abc',
($condition ? 'b' : '') => ($condition ? '123' : ''),
($condition ? 'c' : '') => ($condition ? 'xyz' : ''),
);
$arr = array_filter($arr);
@levonlee
levonlee / AngularJS Chaining Promises for Unknown Amount of Times .md
Created July 17, 2015 21:16
AngularJS Chaining Promises for Unknown Amount of Times

How to chain promises one after another for unknown amount of times? This example shows how chain $timeout using .then()

Each $timeout change the color of a block in a random delay time.

And each one happens one by one for dynamic number of times.

@levonlee
levonlee / AngularJS Create Dynamic Filter using Function for ngRepeat.md
Last active August 29, 2015 14:26
AngularJS Create Dynamic Filter using Function for ngRepeat
@levonlee
levonlee / output-json.cfm
Created July 30, 2015 16:23
Convert ColdFusion Variable to JSON and Output
<!--- Convert a ColdFusion variable to JSON format --->
<cfset s = "I'm a string or URL.">
<cfset numInteger = 1994>
<cfset JSONUtil = createObject("component","functions.JSONUtil")>
<cfoutput>#JSONUtil.serializeJSON(s)#</cfoutput>
<cfoutput>#JSONUtil.serializeJSON(numInteger,0,1)#</cfoutput>
<!--- Read json --->
<cfset strJson = ' {"strerror":"","strsuccess":"Thank you for your message!"}'>