Skip to content

Instantly share code, notes, and snippets.

View rootux's full-sized avatar
🌴
Crafting

Gal Bracha rootux

🌴
Crafting
View GitHub Profile
@reZach
reZach / Terrain Animator
Created June 18, 2019 02:08
Animates Terrain in Game Builder (Steam)
// Example card.
// User-editable properties for this card:
export const PROPS = [
propNumber("ticks", 60),
propBoolean("infinite", true),
propBoolean("completeAnimationDelay", false),
propNumber("completeAnimationDelayMin", 60),
propNumber("completeAnimationDelayMax", 60),
propNumber("forceFrame", -1)
@ywwwtseng
ywwwtseng / host-react-app-on-apache-server.md
Last active March 8, 2024 12:16
Host react application on Apache server

Host react application on Apache server

Step 1 : Create your app

$ npm install -g create-react-app 
$ create-react-app my-app

Step 2 : Build it for production

@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

@cvan
cvan / qs.js
Last active February 21, 2024 13:44
get query-string parameters (alternative to `URLSearchParams`)
var queryParams = window.location.search.substr(1).split('&').reduce(function (qs, query) {
var chunks = query.split('=');
var key = chunks[0];
var value = decodeURIComponent(chunks[1] || '');
var valueLower = value.trim().toLowerCase();
if (valueLower === 'true' || value === 'false') {
value = Boolean(value);
} else if (!isNaN(Number(value))) {
value = Number(value);
}
#!/usr/bin/python
import hashlib, sys
# Simplified version of https://github.com/drupal/drupal/blob/7.x/includes/password.inc
ALGO = hashlib.sha512
ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' # ICHS
@jh0ker
jh0ker / mwt.py
Last active February 3, 2023 20:38
Memoize-with-timeout decorator
#!/usr/bin/env python
# Source: http://code.activestate.com/recipes/325905-memoize-decorator-with-timeout/#c1
import time
from functools import wraps
class MWT:
"""Memoize With Timeout"""
_caches = {}
_timeouts = {}
@PaulTaykalo
PaulTaykalo / Appfile
Created August 26, 2016 13:05
Fastlane's Appfile for multiple users support
# In big teams instead of specifying one email to rule them all as apple_id
# You can get this information from environment variable
# By doing this it will allow different developers to specify their own apple ids
# And if this env variable is not required - then it will be asked on any command that requires apple_id
apple_id ENV["MY_APP_NAME_APPLE_ID"] # Your Apple email address
### ~/.bashrc of some user
export MY_APP_NAME_APPLE_ID="someuser@gmail.com"
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@ldong
ldong / download_egghead_videos.md
Last active December 7, 2023 16:16
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
var Headout = {
apply: function() {
return true;
},
code: function() {
console.log("I", this.a.join(' '), 'code at Headout');
this.a = [];
return this;
},
a: []