Skip to content

Instantly share code, notes, and snippets.

View wolivera's full-sized avatar

Will wolivera

View GitHub Profile
@wolivera
wolivera / Jokes API Postman Collection.json
Created August 5, 2021 16:21
Jokes API Postman Collection
{
"info": {
"_postman_id": "267cb468-eb06-4021-9743-6ba3b0c2139d",
"name": "Jokes API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "GET Random Jokes",
"event": [
@ayavilevich
ayavilevich / aws_ebs_leader.js
Created February 19, 2019 18:28
AWS Elastic Beanstalk "is leader instance" check for use with cron, etc (nodejs, async/await).
// based on https://gist.github.com/tony-gutierrez/de5b304fd042f6140eb61a31d0ff92d5
async function isLeader() {
try {
// get APIs
var elasticbeanstalk = new AWS.ElasticBeanstalk();
var ec2 = new AWS.EC2();
var metadata = new AWS.MetadataService();
// get ec2 instance id
const request = new Promise( (resolve, reject) => { // MetadataService.request has no support for promise, make one ourselves
metadata.request('/latest/meta-data/instance-id', (err, InstanceId) => {
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active June 4, 2024 09:34
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@tomriley
tomriley / mongiod_mysql_migrator.rb
Created April 10, 2014 17:24
Migrate a Mongoid / MongoDB database to an ActiveRecord based SQL one. One method to convert the schema, another to migrate data. Copes with most basic data types. Some hacks to infer TEXT columns. Converts embeds_one relationships to AR aggregations. I wrote this for a one-time migration. It could be a good starting point for someone doing the …
# Migrate schema and data from Mongoid to MySQL ActiveRecord
class MongoidMysqlMigrator
def randomize_auto_increment_values(source_models, from=5500, to=10500)
source_models.each do |model|
value = rand(from-to)+from
sql = %(ALTER TABLE #{model.name.tableize} AUTO_INCREMENT=#{value})
puts sql
ActiveRecord::Base.connection.execute(sql)
end