Skip to content

Instantly share code, notes, and snippets.

Had to install ubuntu on a usb drive when my hard drive crashed.
Seems like in ubuntu 13.10, the usb-creator-gtk is corrupted. I followed a few instructions at
https://help.ubuntu.com/community/Installation/FromUSBStick and finally managed to install ubuntu on a usb drive.
This is waht had to be done before running startup disk creator
sudo add-apt-repository ppa:jmarsden/lubuntu
sudo apt-get update
sudo apt-get install usb-creator-gtk
@ryansukale
ryansukale / phpDebugging.php
Created March 10, 2014 14:40
Two lines of code that can help you debug errors in your php page
ini_set('display_errors', 'On');
error_reporting(E_ALL);
@ryansukale
ryansukale / node-post.js
Last active August 29, 2015 13:57
A simple template of node post - using multiparty instead of bodyparser
/*
Apparently using bodyParser is bad
http://andrewkelley.me/post/do-not-use-bodyparser-with-express-js.html
This is how you'd fetch post parameters using multiparty instead.
*/
var multiparty = require('multiparty');
//Fetching the value of a field in a post parameter
app.post('/yoururl', function(req, res) {
@ryansukale
ryansukale / timeManipulation.php
Last active January 4, 2016 20:19
Php Script demonstrating how to add/subtract dates
$timeInterval = 10;
$timeFactor = 'seconds'; //Can be either 'days', 'hours', 'minutes' or 'seconds'
$now = date("Y-m-d H:i:s");
$futureDate = date('Y-m-d H:i:s', strtotime($now. ' + '. $timeInterval .' '.$timeFactor));
@ryansukale
ryansukale / MysqliInsertUpdate.php
Last active January 4, 2016 20:09
A sample mysqli insert-update statement for strings, numbers and dates.
$now = date("Y-m-d H:i:s");
//Insert
$query = 'insert into '.$tableNamespace.'tableName(field1, field2, field3, field4) values ('.
'"'.$strValue1.'",'.
'"'.$strValue2.'",'.
$intValue3.','.
'"'.$now.'"'.
')';
@ryansukale
ryansukale / ExecuteQuery.php
Last active January 4, 2016 19:59
A simple php snippet for querying data from a database using mysqli
$query="select * from your_table where";
$resultSet = mysqli_query($con,$query);
$size = mysqli_num_rows($resultSet);
if($size>0){
while($resultRow = mysqli_fetch_array($resultSet)){
$fieldValue = $resultRow['field_name'];
}
}
@ryansukale
ryansukale / jquerySnippets
Created January 23, 2014 16:22
Short snippets of code to do commonplace things using jQuery or pure javascript
$(
//Setting the value of a radio button programmatically
$('input[type=radio]').prop('checked', true);
);
@ryansukale
ryansukale / phpForeach
Last active December 31, 2015 04:49
php foreach using a key and a value
foreach ($aMapLikeCollection as $key => $value) {
}
@ryansukale
ryansukale / gist:6927680
Last active December 25, 2015 05:49
A short snippet to randomize elements in an array or a jquery collection.
function randomize(arr) {
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};