Skip to content

Instantly share code, notes, and snippets.

View the-vampiire's full-sized avatar
💭
ive lost a shade of color in my life. rest in peace.

the-vampiire

💭
ive lost a shade of color in my life. rest in peace.
View GitHub Profile

Ok, so, you might know about JavaScript regular expressions. Well, here is a tutorial about them, but written by a 13 year old, so it isn't actually any good!

Regular expressions go between / characters. Here is an exampe, /hi/.

Ok, now then. Let's learn how to match the string abc. Well, that's quite simple.

/abc/. Yey! So putting letters next to each other makes them match one after the other.

Ok, now, after the second / we can put a g to make it match globally, that is, we can extract abc from xyzabcghi.

Ok, so, you might know about JavaScript regular expressions. Well, here is a tutorial about them, but written by a 13 year old, so it isn't actually any good!

Regular expressions go between / characters. Here is an exampe, /hi/.

Ok, now then. Let's learn how to match the string abc. Well, that's quite simple.

/abc/. Yey! So putting letters next to each other makes them match one after the other.

Ok, now, after the second / we can put a g to make it match globally, that is, we can extract abc from xyzabcghi.

@coreh
coreh / batch-invite.js
Last active April 30, 2020 00:48
Invite users to a slack room / group as a batch
// Instructions: Open slack, switch to the channel you want to invite people to,
// Copy and paste the entire code snippet below to the "Console" tab of your web inspector, hit "Enter".
(function () {
var people = prompt('Paste the usernames you want to invite here and hit OK:').split(/,\s*|\s+/);
var textArea = $('#message-input');
var dismiss = function () {
$(".dialog_go").click();
}
@lorenzorapetti
lorenzorapetti / BaseModel.js
Created February 18, 2018 16:57
Custom validation in objection.js
const { Model, AjvValidator } = require('objection');
const pluralize = require('pluralize');
class BaseModel extends Model {
/**
* Always use timestamps as default
*/
static get timestamps() {
return true;
}
@d11wtq
d11wtq / enum.sql
Created October 26, 2012 10:07
Renaming an ENUM label in PostgreSQL
/*
Assuming you have an enum type like this.
You want to rename 'pending' to 'lodged'
*/
CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled');
BEGIN;
ALTER TYPE dispute_status ADD VALUE 'lodged';
UPDATE dispute SET status = 'lodged' WHERE status = 'pending';
@nzaghini
nzaghini / Movie-test.js
Last active September 23, 2022 17:03
Apollo GraphQL Test Example with Jest
import fs from 'fs'
import { makeExecutableSchema } from 'graphql-tools'
import { graphql } from 'graphql'
// the actual resolvers
import resolvers from '../src/resolvers'
// the mock service
import mockMovieService from './mocks/mockMovieService'
// a nice structure for test cases
// found at https://hackernoon.com/extensive-graphql-testing-57e8760f1c25
@laurenfazah
laurenfazah / express_postgress_knex.md
Last active November 26, 2022 13:19
Cheat Sheet: Setting up Express with Postgres via Knex

Express & Postgres via Knex

Note: <example> is meant to denote text replaced by you (including brackets).

Setup

// global dependencies
npm install -g knex
@iamerikjolson
iamerikjolson / ChromebookDev.md
Last active July 18, 2023 09:07
How to setup your Chromebook as a dev box

These instructions will not work on Chromebooks with an ARM processor. If you have an ARM processor then you cannot install Chromebrew to get git. You'll need to instead install crouton. Here are instructions that you can follow: https://github.com/macton/arch-linux-install-notes/tree/master/arm-chromebook-chroot

#Configuring Chromebook for Development

After a full Sunday of trial and error, and stepping through many semi-complete or dated blog posts explaining how to do this, I was able to get the Chromebook into developer mode, install git, Node.js, and NPM.

Here's what I did...

  1. Enable Developer Mode
  • Press Esc-Refresh-Power keys which will reboot the Chromebook
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@stephantabor
stephantabor / bb.js
Last active January 6, 2024 04:18
Bluebird .each vs .mapSeries vs .map
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
funcs
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
funcs
.mapSeries(iterator) // logs: 500, 100, 400, 200