Skip to content

Instantly share code, notes, and snippets.

View noodlehaus's full-sized avatar

noodlehaus noodlehaus

View GitHub Profile
@danielwetan
danielwetan / nodejs-cicd-github-actions.md
Last active June 24, 2024 00:16
Deploy Node.js to VPS using Github Actions

Deploy Node.js to VPS using Github Actions

Steps to deploy Node.js to VPS using PM2 and Github Actions

1. Clone repo to VPS folder

@pamelafox
pamelafox / pokemon.sql
Created March 20, 2020 16:51
Pokemon statistics
CREATE TABLE pokemon(
Number INTEGER,
Name TEXT PRIMARY KEY,
Type_1 TEXT,
Type_2 TEXT,
Total INTEGER,
HP INTEGER,
Attack INTEGER,
Defense INTEGER,
Sp_Atk INTEGER,
@lirsacc
lirsacc / script.py
Last active May 22, 2024 12:33
Playing with Python's operator overloading to support the pipe functional operator from Elixir.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Small experiment with Python's operator overloading to add support for
composing function with the pipe operator similar to Elixir's pipe operator.
The main use case of such technique I see is to build isolated DSL.
This approach uses decorators to achieve the given result which forces you
to wrap all the functions you want to use this way. The runtime cost should
be minimal however this might be a problem in some context. It also prevents you
<?php
class _╯°□°╯︵┻━┻ extends \Exception {}
function _╯°□°╯︵┻━┻($message) {
throw new _╯°□°╯︵┻━┻($message);
}
_╯°□°╯︵┻━┻("Flip Table");
@tbarbugli
tbarbugli / How to build a notification feed php.md
Last active August 29, 2015 14:16
How to build a notification feed using Stream

How to build a notification feed using Stream

Introduction

In this tutorial we are going to show how easy it is to build a notification feed using GetStream.io. First of all, let's quickly introduce you to our fictional example app. It's called bug-your-friends.com and allows you interact with your friends, ping them, follow them or poke them. Here's a quick list of example interactions:

  • poke another user (eg. Thierry pokes Alessandra)
  • follow a user (eg. Tommaso follows Iris)
  • ping a user (eg. Josie pings Carolina)

Whenever a user is part of one of these interactions, we want to update his notification feed, update the number of unseen and unread

@noodlehaus
noodlehaus / .bashrc
Created March 2, 2015 01:35
bash prompt
# get bash completion for brew
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# git prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}
@justmoon
justmoon / custom-error.js
Last active June 26, 2024 09:36 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@jkresner
jkresner / index.hbs
Last active August 29, 2015 14:13
Node.js Express Login with PayPal Integration (ES6)
<h1>Paypal Login</h1>
<a href="{{paypalLoginUrl}}"><img src="https://www.paypalobjects.com/webstatic/en_US/developer/docs/lipp/loginwithpaypalbutton.png" /></a>
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

<?php
use http\Client, http\Client\Request;
use http\QueryString;
$params = new QueryString;
$params["foo"] = "bar";
$params["bar"] = "foo";
$request = new Request("POST", "http://example.com");