Skip to content

Instantly share code, notes, and snippets.

View salzhrani's full-sized avatar

Samy Al Zahrani salzhrani

View GitHub Profile
@psteinroe
psteinroe / Dockerfile
Last active June 20, 2022 02:01
cd.yaml
FROM node:fermium-alpine AS builder
WORKDIR /app/builder
COPY . .
# https://github.com/nodejs/docker-node/issues/384#issuecomment-305208112
RUN apk --no-cache add --virtual native-deps \
git g++ gcc libgcc libstdc++ linux-headers make python && \
yarn global add --silent node-gyp &&\
yarn --silent && \
apk del native-deps
@001101
001101 / accounting.sql
Created February 18, 2017 09:08 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@maisano
maisano / RouteTransition.jsx
Last active September 15, 2023 07:29
Using react-motion with react-router
import React, { PropTypes } from 'react';
import { TransitionMotion, spring } from 'react-motion';
/**
* One example of using react-motion (0.3.0) within react-router (v1.0.0-rc3).
*
* Usage is simple, and really only requires two things–both of which are
* injected into your app via react-router–pathname and children:
*
* <RouteTransition pathname={this.props.pathname}>
@obolton
obolton / elb-nodejs-ws.md
Last active November 12, 2023 11:49
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@tkafka
tkafka / LICENSE.txt
Last active May 17, 2024 02:08
Drop-in replacement for ReactCSSTransitionGroup that uses velocity.js instead of CSS transforms. Add your own transitions to `transitions` hash.
The MIT License (MIT)
Copyright (c) 2014 Tomas Kafka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@katowulf
katowulf / 1_using_queries.js
Last active April 24, 2023 07:14
Methods to search for user accounts by email address in Firebase
/***************************************************
* Simple and elegant, no code complexity
* Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records)
* (This disadvantage should go away as we add optimizations to the core product)
***************************************************/
var fb = firebase.database.ref();
/**
* @param {string} emailAddress
@lukemelia
lukemelia / buffered_proxy.js
Last active May 5, 2016 20:47
Buffered Proxy, extracted from Yapp codebase
var empty, get, set,
__hasProp = {}.hasOwnProperty;
get = Ember.get;
set = Ember.set;
empty = function(obj) {
var key;
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;
@kharmabum
kharmabum / node-aws-setup.txt
Created May 21, 2013 04:22
Setting up 64bit Linux on AWS for Node.js
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
sudo yum install git-core
sudo yum install emacs
# Install nvm: node-version manager
# https://github.com/creationix/nvm
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
# Install rlwrap to provide libreadline features with node # See: http://nodejs.org/api/repl.html#repl_repl
sudo yum install readline-devel
@thehydroimpulse
thehydroimpulse / index.html
Last active December 12, 2015 09:09
Splitting ember.js compilation on both the server (Node.js) and client-side. This would solve search engine crawling, speed, and some others. I also gota simple server side implementation. Had to port ember-view to node.js. things are still somewhat unstable. Some issues on the server : * Lack of Router * This means Controllers and Views are not…
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Fast Boot</title>
</head>
<body>
<!-- Main application template -->
<script type="text/x-handlebars" data-template-name="application">
Application Template - {{name}}