Skip to content

Instantly share code, notes, and snippets.

View BastinRobin's full-sized avatar
🏠
Working from home

Bastin Robin BastinRobin

🏠
Working from home
View GitHub Profile
@BastinRobin
BastinRobin / error.js
Created August 13, 2014 09:49
Javascript Error Logger
function log(e, msg) {
for (var i in e) { msg += i + "=" + e[i] + "\n"; }
(new Image()).src="log.pl?m=" + encodeURIComponent(msg);
}
function abc() {
try {
// ... function code
} catch(e) { log(e, "abc"); }
}
<?php
/*
|--------------------------------------------------------------------------
| Return a Collection of Objects
|--------------------------------------------------------------------------
*/
// collection of all users
$sql = "select * from users";
@BastinRobin
BastinRobin / georadiusquery.php
Last active August 29, 2015 14:06
Geo Location Search Using Radius
public function getLocation() {
$lat = 37;
$lon = -122;
$radius = 40;
$result = Zipcode::select(
DB::raw("*,
( 3959 * acos( cos( radians(?) ) *
cos( radians( lat ) )
* cos( radians( lng ) - radians(?)
) + sin( radians(?) ) *
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@BastinRobin
BastinRobin / Filter JSOn
Last active August 29, 2015 14:10
Sushant JSON
data = [
{
"Compound_id":133,
"Compound_name":"carbofuran",
"Protein_id":858,
"Protein_name":"CDs 1",
"Type":"possible",
"RScore":31,
"combination_id":"133_858"
},
// Routes.php
Route::get('upload', function()
{
return View::make('upload-form');
});
Route::post('upload', function()
{
// Get and move uploaded file.
@BastinRobin
BastinRobin / youtube.py
Created January 11, 2015 14:46
Youtube Scrapper
import pafy
url = raw_input ("Enter your URL : ")
# Instantiation
video = pafy.new (url)
#Users Choice
print "1 => Download || 2 => Extract"
choice = raw_input ( "Input d To Download or ei To Extract Information : ")
<?php
// This creates a date string in the format YYYY-WNN, which is
// a four digit year followed by a hyphen and letter W then the
// two digit week number
$strtotime = date("o-\WW");
// The $start timestamp contains the timestamp at 0:00 on the
// Monday at the beginning of the week
$start = strtotime($strtotime);
@BastinRobin
BastinRobin / Email.txt
Created March 21, 2015 06:48
Generic Email List
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
150ml.com
15meg4free.com
163.com