Skip to content

Instantly share code, notes, and snippets.

Avatar

Lakshan Perera laktek

View GitHub Profile
View gist:bb25c2b073f5052883edc04c2bd789fe
Verifying my Blockstack ID is secured with the address 1BStSSHb6QbagrSqSuWrX64yibNNdM8hd4 https://explorer.blockstack.org/address/1BStSSHb6QbagrSqSuWrX64yibNNdM8hd4
View server.js
const express = require('express')
const bodyParser = require('body-parser')
const expressValidator = require('express-validator')
const routes = require('./routes')
const middlewares = require('./middlewares')
const errorHandlers = require('./middlewares/errorHandlers')
const isProduction = process.env.NODE_ENV === 'production'
const passport = require('passport')
const mongoose = require('mongoose')
View app.js
export default class App {
constructor(userHandler){
this.userHandler = userHandler;
}
async testing(req, res) => {
const { email } = req.body
const r = await this.userHandler.findOne({email})
res.json(r)
}
View gist:74a531d841e4d5c340f0
package main
import (
"fmt"
"net/http"
"time"
)
/*
* Converts a function that return a channel
View relative_path_helper.js
var generate_tag_helpers_with_basepath = function(basePath) {
return {
relative_path: function() {
var pathDepth = basePath.split('/').length -2;
var path = new Array(pathDepth + 1).join('../');
return path;
}
}
};
@laktek
laktek / gist:1631290
Created Jan 18, 2012
Wikipedia SOPA protest unmask
View gist:1631290
// If you need to unmask the Wikipedia's SOPA protest blackout,
// paste this in your browser's address bar.
javascript:(function(d){d.getElementById('mw-sopaOverlay').style.display='none'; d.getElementById('content').style.display='block';})(document);
View gist:871014
var my_function_expression = function(){};
var mocked = nodemock.mock("foo").takes(20, my_function_expression).calls(my_function_expression, 30, [10, 20])
@laktek
laktek / jquery.is_blank.js
Created Dec 29, 2010
Checks whether the given string (or object) is blank
View jquery.is_blank.js
(function($){
$.isBlank = function(string){
return(!string || $.trim(string) === "");
};
})(jQuery);
$.isBlank(" ") //true
$.isBlank("") //true
$.isBlank("\n") //true
$.isBlank("a") //false
View gist:456875
/**
* jQuery plugin to detect clicks outside an element
*
* Copyright (c) 2010 Vesess Inc. (vesess.com)
* Licensed under the MIT (MIT-LICENSE.txt) licenses.
*
*/
(function($){
$.fn.outsideClick = function(optional_params){
View gist:456866
/**
* jQuery plugin to detect clicks outside an element
*
* Copyright (c) 2010 Vesess Inc. (vesess.com)
* Licensed under the MIT (MIT-LICENSE.txt) licenses.
*
*/
(function($){
$.fn.outsideClick = function(optional_params){
You can’t perform that action at this time.