Skip to content

Instantly share code, notes, and snippets.

@stormbreakers
stormbreakers / stateCity.js
Created April 15, 2016 07:04
Indian state and cities in array
var stateCity = [
{'stateName':'Andaman and Nicobar Islands','cityName':[
{'city':'Port Blair'}
]},
{'stateName':'Andhra Pradesh','cityName':[
{'city':'Visakhapatnam'},
{'city':'Vijayawada'},
{'city':'Guntur'},
{'city':'Nellore'},
{'city':'Kurnool'},
@stormbreakers
stormbreakers / parsely_custom_validator.js
Last active June 1, 2016 13:17
custom validation using parsleyjs
var parseDate = function(s) {
var re = /^(\d\d)-(\d\d)-(\d{4}) (\d\d):(\d\d):(\d\d)$/;
var m = re.exec(s);
return m ? new Date(m[3], m[2]-1, m[1], m[4], m[5], m[6]) : null;
};
window.ParsleyValidator
.addValidator('checkEndDate', function (value, requirement) {
var endDate = new Date(parseDate(value).toString());
var startDate = new Date(parseDate($(requirement).val()).toString());
return Date.parse(startDate) <= Date.parse(endDate);
@stormbreakers
stormbreakers / shell_exec.php
Created September 19, 2016 09:42
importing .csv file in linux
mysqlimport --ignore-lines=1 --lines-terminated-by='\r\n' --fields-optionally-enclosed-by='\"' --fields-terminated-by=, --local -u root -paspire@123 aspire_development ".$fileCsv
<?php
if (!(Auth::user()->active == 1)) {
Auth::logout();
return redirect('sign-in')->with('error', 'Inactive User, Please check with the administrator');
}
DB::enableQueryLog();
$currentRouteName = Route::getCurrentRoute()->getName();
lat = ^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6};
lng = ^-?([1]?[1-7][1-9]|[1]?[1-8][0]|[1-9]?[0-9])\.{1}\d{1,6}
email = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

$string = 'Maramures';
if ( preg_match("~\bMures\b~",$string) )
echo "matched";
else
echo "no match";
mutation {
addPerson(firstName: "Joy", lastName: "Koli", email: "joyk.ixltech@gmail.com") {
firstName
lastName
email
id
}
}
const crypto = require('crypto');
const alogrithm = 'aes-256-cbc';
const ENCRYPTION_KEY = '770A8A65DA156D24EE2A093277530142';
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv(alogrithm, new Buffer(ENCRYPTION_KEY), iv);
let encrypted = cipher.update(text);