Skip to content

Instantly share code, notes, and snippets.

View OlivierJM's full-sized avatar

ojm OlivierJM

View GitHub Profile
@stewartduffy
stewartduffy / gist:481f21ea4906e611d934
Last active June 24, 2024 07:37
Regex to remove file extension from JS string.
var filenameFull = "tm_icons.png";
//Regex to remove
var filenameText = filenameFull.replace(/\.[^/.]+$/, "");

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@joshnuss
joshnuss / app.js
Last active February 18, 2025 15:49
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@Stoffo
Stoffo / remove_documents_mongodb.js
Created October 29, 2015 12:29
Remove Documents older than x days in MongoDB
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@pmontrasio
pmontrasio / safe_s3.rb
Last active December 23, 2021 08:37
Compress a file, encrypt it, upload it to S3. Download, decrypt, uncompress.
#!/bin/env/ruby
# gem "aws-sdk", "~> 2"
require "rubygems"
require "zlib"
require "rubygems/package"
require "securerandom"
gem "aws-sdk"
require "aws-sdk"
@cynipe
cynipe / mitchellh_cli.go
Created January 17, 2016 03:07
Golang CLI Example
package main
import (
"os"
"fmt"
"github.com/mitchellh/cli"
)
func main() {
@vasanthk
vasanthk / System Design.md
Last active April 24, 2025 13:48
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@briandk
briandk / CONTRIBUTING.md
Created March 18, 2016 20:29
A basic template for contributing guidelines that I adapted from Facebook's open source guidelines

Contributing to Transcriptase

We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

We Develop with Github

@sunnygleason
sunnygleason / garage.js
Created August 28, 2016 22:59
Liftmaster Garage Control Integration w/ PubNub and Node.JS
var CTRL_CHAN, DOOR_STATES, HOME_CHAN, LIFTMASTER_PASSWORD, LIFTMASTER_USERNAME,
MyQ, PUB_KEY, PubNub, SUB_KEY, garage, initPubNub, makeHandler, pubnubConns,
refreshStatus, _;
_ = require('underscore');
MyQ = require('liftmaster');
PubNub = require('pubnub');
LIFTMASTER_USERNAME = 'YOUR_LIFTMASTER_USERNAME';
LIFTMASTER_PASSWORD = 'YOUR_LIFTMASTER_PASSWORD';
@chand
chand / rails-drop-tablemigration-model-controller.md
Last active November 21, 2024 10:44
Drop Table, Model, Migration in Rails

Dropping Migration Table, Models, Controller

Command Line

1. Drop Table/Migration

rails generate migration DropTablename

A file will be created, in the db > migrate folder, make sure it looks like: