Skip to content

Instantly share code, notes, and snippets.

View natchiketa's full-sized avatar

Sara Lara natchiketa

View GitHub Profile
@gullyn
gullyn / flappy.html
Last active November 28, 2023 18:23
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>
// This example gives permission to access geolocation
// and fetches the current position via JavaScript.
// Tested on: cdp v0.18.7 and Chrome Canary 70.0.3532.0,
// and seems to work in both headless and headfull mode.
package main
import (
"context"
"fmt"
"log"
@jacob-beltran
jacob-beltran / requestAnimationFrame.js
Last active April 17, 2020 04:05
React Performance: requestAnimationFrame Example
// How to ensure that our animation loop ends on component unount
componentDidMount() {
this.startLoop();
}
componentWillUnmount() {
this.stopLoop();
}
@weedySeaDragon
weedySeaDragon / rspec-shared-context-examples-optional.rb
Last active February 11, 2022 00:23
Using shared_context and shared_examples in Rspec with optional arguments. Answer to SO 24872199
#-------------------------- #
#
# @author Ashley Engelund (ashley@ashleycaroline.com weedySeaDragon @ github)
# @date 1/13/17
#
# @desc This is my answer to the Stack Overflow (SO) question:
# How can I use a default method to create something in a shared_example,
# sometimes overriding it with some other method and parameters for it?
#
# @see http://stackoverflow.com/questions/24872199/rspec-with-reusable-method-for-shared-examples-context
@manasthakur
manasthakur / plugins.md
Last active May 2, 2024 05:48
Managing plugins in Vim

Managing plugins in Vim: The basics

Let's say the plugin is at a GitHub URL https://github.com/manasthakur/foo. First get the plugin by either cloning it (git clone https://github.com/manasthakur.foo.git) or simply downloading it as a zip (from its GitHub page).

Adding a plugin in Vim is equivalent to adding the plugin's code properly into its runtimepath (includes the $HOME/.vim directory by default). For example, if the layout of a plugin foo is as follows:

foo/autoload/foo.vim
foo/plugin/foo.vim
@tomfa
tomfa / cwlogsSlack.js
Last active July 31, 2022 14:30
AWS Lambda function CloudWatch Logs -> Slack
var aws = require('aws-sdk'),
https = require('https'),
zlib = require('zlib'),
util = require('util');
// If you've used KMS to encrypt your slack, insert your CiphertextBlob here
var ENCRYPTED_URL = 'AQEC1423...';
// IF NOT, you can take the risk to insert your Slack URL here
// e.g. '/services/QWERTY/ASDFGHJ/zxYTinNLK';
@elijahmanor
elijahmanor / pros-cons-npmscripts-vs-gulp.md
Last active February 20, 2022 12:46
Pros and Cons of `npm scripts` vs Gulp

Comparison of npm scripts vs Gulp

npm scripts

Pros

  • npm scripts are low-level and leverage the actual library you want to use (example: "lint": "eslint ./")
  • package.json is a central place to see what scripts are available (also npm run will list all scripts)
  • When things get too complicated you can always defer to another file (example: "complex-script": "babel-node tools/complex-script.js")
  • npm scripts are more powerful than one might first think (pre/post hooks, passing arguments, config variables, chaining, piping, etc...)
@yoavniran
yoavniran / mocha-hooks-order.js
Created April 11, 2015 13:35
shows how mocha hooks are ordered and run within contexts
describe("root context", function(){
before(function(){
console.log("before: root");
});
beforeEach(function(){
console.log("beforeEach: root");
});
@wh1tney
wh1tney / deploy-static-site-heroku.md
Last active April 23, 2024 17:49
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@matuu
matuu / Postgres-create-user-db
Last active July 8, 2016 15:30
Postgres, create user & db
Option 1
su - postgres
psql template1
CREATE USER tom WITH PASSWORD 'myPassword';
CREATE DATABASE jerry;
GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
Option 2:
su postgres
postgres@debian: createuser tom