Skip to content

Instantly share code, notes, and snippets.

View mongodb_aggregate_query.txt
db.cohorts.aggregate([
{
"$match": { "journeyId": "4f1f0071fbe1093a8281" }
},
{
$project: {
_id: {
"$toString": "$_id"
},
testCohort: 1,
View encrypt_decrpyt.js
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);
View graphql_mutation_query_example.js
mutation {
addPerson(firstName: "Joy", lastName: "Koli", email: "joyk.ixltech@gmail.com") {
firstName
lastName
email
id
}
}
View excat_word_match.php
$string = 'Maramures';
if ( preg_match("~\bMures\b~",$string) )
echo "matched";
else
echo "no match";
View Readme.md

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

View regex.js
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;
View navigation.blade.php
<?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();
@stormbreakers
stormbreakers / shell_exec.php
Created Sep 19, 2016
importing .csv file in linux
View shell_exec.php
mysqlimport --ignore-lines=1 --lines-terminated-by='\r\n' --fields-optionally-enclosed-by='\"' --fields-terminated-by=, --local -u root -paspire@123 aspire_development ".$fileCsv
@stormbreakers
stormbreakers / parsely_custom_validator.js
Last active Jun 1, 2016
custom validation using parsleyjs
View parsely_custom_validator.js
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);