Skip to content

Instantly share code, notes, and snippets.

View adamgen's full-sized avatar
🚀
Developing software, and software developers 🤖

Adam adamgen

🚀
Developing software, and software developers 🤖
View GitHub Profile
@adamgen
adamgen / angular-router-remove-hash.js
Created August 25, 2015 12:09
angular router remove hash
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode(true);
$locationProvider.baseHref = '/';
UPDATE `wp_postmeta`
SET `meta_value` = replace(meta_value , 'http://boredomtherapy.com', 'https://local.bt.com')
import numpy as np
def is_int(s):
try:
int(s)
return True
except ValueError:
return False
@adamgen
adamgen / timedatectl list-timezones
Created April 10, 2017 09:36
An online display timedatectl list-timezones list
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
<!--JQUERY-->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<!--BOOTSTRAP-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
@adamgen
adamgen / user_controller.js
Created June 7, 2018 04:52
Passport JWT middleware
const url = require('url');
const router = require('express').Router();
const passport = require('passport');
const jwt = require('jsonwebtoken');
const User = require('../schemas/user');
router.post('/register', (req, res) => {
if(!(req.body.email && req.body.password)) return res.status(200).send('no password or email provided');
User.findByEmail(req.body.email, (err, user) => {
if(user.length > 0) return res.status(200).send('user with given email exists');
// change old_key_name with new_key_name
db.collection.find().forEach(function(document) {
var old_key_name = document.old_key_name;
db.collection.update(
{ _id: document._id },
{
$set: {
new_key_name: old_key_name,
},
type a = 'aaa';
const b = 'a' + 'a' + 'a';
let c: a;
const IsA = (string: string): string is a => string === 'aaa';
c = b; // gives an error
if (IsA(b)) {
// any type of callable
type callable = (...args: any[]) => any;
// only acept values of object T
type ValueOf<T> = T[keyof T];
getAtts = (elem) => {
const attrs = {};
Object.values(elem.attributes).forEach(attr => {
attrs[attr.name] = attr.value;
});
return attrs
}
atts = getAtts($0);
d3Str = '';
d3Str += `.append('${$0.tagName}')\n`