Skip to content

Instantly share code, notes, and snippets.

@DavidWells
DavidWells / github-proxy-client.js
Last active June 27, 2024 14:52
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@heygema
heygema / Post.test.ts
Last active February 23, 2021 06:14
Prisma TDD
import { createTestContext } from "./__helpers";
const ctx = createTestContext();
it("ensures that draft can be created and published", async () => {
const draftResult = await ctx.client.request(
`
mutation {
createDraft(title: "Nexus", body: "...") {
id
@dustinrouillard
dustinrouillard / snowflake.sql
Created January 17, 2021 02:34
PostgreSQL Snowflake ID Generator Function
CREATE SEQUENCE IF NOT EXISTS public.global_id_sequence;
CREATE OR REPLACE FUNCTION id_generator(OUT result BIGINT) AS $$
DECLARE
epoch BIGINT := 1610850820000;
seq_id BIGINT;
now_millis BIGINT;
shard_id INT := 1;
BEGIN
SELECT nextval('public.global_id_sequence') % 1024 INTO seq_id;
<plist version="1.0">
<dict>
<key>author</key>
<string>IceTimux (http://icetimux.com)</string>
<key>name</key>
<string>One Dark</string>
<key>semanticClass</key>
<string>theme.dark.one_dark</string>
<key>colorSpaceName</key>
<string>sRGB</string>
@hygull
hygull / LICENSE KEY FOR SUBLIME TEXT 3 BUILD 3143.md
Last active December 16, 2023 19:30
LICENSE KEY FOR SUBLIME TEXT 3 BUILD 3143

STEPS

  • Click on Help menu

  • Select Enter License

  • Then paste given KEY given at bottom

  • Finally click on Use License

@haskaalo
haskaalo / tarcheatsheet.md
Last active October 29, 2024 04:00
Tar usage / Tar Cheat Sheet

Tar Usage / Cheat Sheet

Compress a file or directory

e.g: tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

  • -c: Create an archive.
  • -z: Compress the archive with gzip.
  • -v: makes tar talk a lot. Verbose output shows you all the files being archived and much.
  • -f: Allows you to specify the filename of the archive.
@nateinaction
nateinaction / react-firebase-auth.js
Last active November 21, 2022 14:44
This is a version of Facebook's React Conditional Rendering example modified to support firebase authentication.
/*
* This is a version of Facebook's React Conditional Rendering
* example modified to support firebase authentication.
* https://facebook.github.io/react/docs/conditional-rendering.html
*/
import React, { Component, PropTypes } from 'react';
import * as firebase from 'firebase';
function UserAvatar(props) {
function loggedIn() {
// ...
}
function requireAuth(nextState, replace) {
if (!loggedIn()) {
replace({
pathname: '/login'
})
}
@molsches
molsches / gist:d4ec0c18794a069b1811
Created February 26, 2015 21:26
Building Node from source on Ubuntu
//Make a directory to hold the node
mkdir node-install-dir
cd node-install-dir
//Curl and unzip latest node
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
//Install gcc and g++
sudo apt-get update
sudo apt-get install make gcc g++ apache2
@CrazyMORF
CrazyMORF / MacOS_like_box-shadow.css
Last active November 20, 2023 20:22
MacOS like box-shadow
.box {
box-shadow: 0 22px 70px 4px rgba(0, 0, 0, 0.56);
}