This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_to_select($results, $value = 'id', $key = 'title', $add_blank=false) | |
{ | |
// Converts objects to arrays | |
if(is_object($results)) $results = get_object_vars($results); | |
$options = array(); | |
if(!empty($add_blank)) $options = array(null=>$add_blank); | |
// Will only run if results is an array, not a string, int, etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetSingularValuesArray($arr) | |
{ | |
$result=array(); | |
foreach($arr as $key=>$value): | |
$temp=key($value); | |
$result[]=is_object($value)?$value->$temp:$value[$temp]; | |
endforeach; | |
return $result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql_query("Update awards set `active` = if(`active`=0,1,0) where `id`={$_GET['id']}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML : | |
<input type="text" name="userid" /> | |
JAVAASCRIPT : | |
<script> | |
jQuery.noConflict(); | |
jQuery(document).ready(function(){ | |
jQuery('#userid').autocomplete({source:function(request,response){ | |
jQuery.ajax({ | |
type:'post', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cmp($a, $b) { | |
if ($a['TotalEarnings'] == $b['TotalEarnings']) { | |
return 0; | |
} | |
if ($_GET['sortby'] == "earnings"): | |
$orderBy = ($_GET['order'] == 'a') ? "DESC" : "ASC"; | |
endif; | |
if ($orderBy == "DESC"): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- need to add jquery and jquery.cookie.js--> | |
<body onload="loadLocation()"> | |
<div id="container"> | |
<div class="inner-container"> | |
<div class="box box-50"> | |
<div class="boxin"> | |
<div class="header"> | |
<h3>HTML5 Geo-Location</h3> | |
</div> | |
<div class="content"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if nested property exists or not | |
var propertyexists = (objectname,path) => path.split(".").reduce((k,v) => (typeof k=="undefined")?k:k[v],objectname); | |
var myobject = {info:{name:"vibhas"}}; | |
console.log(propertyexists(myobject,"info.name.jhgfdsa.asdfghj")); | |
// If exists it return that value or "undefined" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reject(obj, keys) { | |
return Object.keys(obj) | |
.filter(k => !keys.includes(k)) | |
.map(k => Object.assign({}, {[k]: obj[k]})) | |
.reduce((res, o) => Object.assign(res, o), {}); | |
} | |
console.log(reject({a: 2, b: 3, c: 4}, ['a', 'b'])); |
OlderNewer