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
@april
april / arena-macos-fixes.sh
Last active March 14, 2024 04:48
Fixes Magic Arena's broken full screen implementation on macOS
# this forces Arena into full screen mode on startup, set back to 3 to reset
# note that if you go into the Arena "Graphics" preference panel, it will reset all of these
# and you will need to run these commands again
defaults write com.wizards.mtga "Screenmanager Fullscreen mode" -integer 0
defaults write com.wizards.mtga "Screenmanager Resolution Use Native" -integer 0
# you can also replace the long complicated integer bit with any other scaled 16:9
# resolution your system supports.
# to find the scaled resolutions, go to System Preferences --> Display and then
# divide the width by 16 and multiple by 9. on my personal system this ends up
@dixneuf19
dixneuf19 / zsh-virtualenv-setup.md
Last active April 16, 2024 21:41 — forked from hminnovation/zsh-virtualenv-setup.md
Setup python, pip, virtualenv and virtualwrapper, with zsh on a new machine
@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
@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;
}
@ErikAugust
ErikAugust / spectre.c
Last active April 15, 2024 13:55
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@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
@mort3za
mort3za / git-auto-sign-commits.sh
Last active January 30, 2024 10:31
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
@zcaceres
zcaceres / Include-in-Sequelize.md
Last active January 8, 2024 07:14
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

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.