Skip to content

Instantly share code, notes, and snippets.

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

Manot Luijiu ManotLuijiu

🏠
Working from home
View GitHub Profile
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
@mattmakai
mattmakai / app.py
Created May 30, 2016 18:13
Simple Python & Flask app to respond to incoming SMS text messages
from flask import Flask, Response, request
from twilio import twiml
app = Flask(__name__)
@app.route("/")
def check_app():
# returns a simple string stating the app is working
@ludwig
ludwig / logger.js
Created August 25, 2016 10:10 — forked from transitive-bullshit/logger.js
winston logger with filename:linenumber
// NOTE: this adds a filename and line number to winston's output
// Example output: 'info (routes/index.js:34) GET 200 /index'
var winston = require('winston')
var path = require('path')
var PROJECT_ROOT = path.join(__dirname, '..')
var logger = new winston.logger({ ... })
// this allows winston to handle output from express' morgan middleware
# This is a sample build configuration for Javascript.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:6.9.2
pipelines:
branches:
master:
@layerlre
layerlre / IDCardUtil.java
Created March 27, 2017 06:25
Validate thai ID card
public class IDCardUtil {
public static boolean isValid(String idCard){
if (idCard.length()!=13){
return false;
}
int sum = 0;
for (int i = 0; i < 12; i++) {
sum += Character.getNumericValue(idCard.charAt(i))*(13-i);
}
@nurrony
nurrony / handler.js
Created March 28, 2017 12:10 — forked from jonascheng/handler.js
AWS Lambda blueprint cloudwatch-alarm-to-slack
'use strict';
/**
* Follow these steps to configure the webhook in Slack:
*
* 1. Navigate to https://<your-team-domain>.slack.com/services/new
*
* 2. Search for and select "Incoming WebHooks".
*
* 3. Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
@jonchurch
jonchurch / lex-response.js
Last active September 27, 2018 10:09
Valid ElicitSlot AWS Lex Lambda response
'use strict';
exports.handler = (event, context, callback) => {
// Currently all possible fields
// {
// "sessionAttributes": {
// "key1": "value1",
// "key2": "value2"
// ...
// },
@remy
remy / next.config.js
Created July 18, 2017 18:37
Next.js configuration for dotenv and custom servers.
const webpack = require('webpack');
require('dotenv').config({
path: process.env.NODE_ENV === 'production' ? '.env.production' : '.env'
});
module.exports = {
webpack: config => {
const env = Object.keys(process.env).reduce((acc, curr) => {
acc[`process.env.${curr}`] = JSON.stringify(process.env[curr]);
@cklanac
cklanac / logger.js
Created August 15, 2017 20:53
Morgan, Winston and Loggly
'use strict';
const { LOGGLY_TOKEN } = require('../config');
/**
* [Winston](https://github.com/winstonjs/winston)
* A multi-tranport async logging library
*
* Use winston to implement our logger, but the rest of the app uses
* the generic logger interface that we export. This decouples logging
* logic in our code from implementation with Winston.