Skip to content

Instantly share code, notes, and snippets.

View lifeofcoding's full-sized avatar
💭
4RwPdnGala2QfMua

Jimmy Rousseau lifeofcoding

💭
4RwPdnGala2QfMua
View GitHub Profile
#!/bin/sh
#
# Script to start CPU limit daemon
#
set -e
case "$1" in
start)
if [ $(ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh" {print $1}' | wc -l) -eq 0 ]; then
nohup /usr/bin/cpulimit_daemon.sh >/dev/null 2>&1 &
const EventEmitter = require('events')
const electron = require('electron')
export default class EventBus extends EventEmitter {
constructor(name='default') {
super()
this._name = name
this._baseEventKey = `EventBus-${name}:`
}
@lifeofcoding
lifeofcoding / updatenoip.sh
Created April 23, 2020 01:48 — forked from mbierman/updatenoip.sh
Update no IP address
#!/bin/bash
###############################################################
## ChangeIP.com bash update script
###############################################################
## Written 3/18/09 by Tom Rinker, released to the Public Domain
## Re-write 09/15/2017 by Michael Bierman
## I replaced wget with curl so it can work on all macs.
## This works with no-ip.com
###############################################################
@lifeofcoding
lifeofcoding / ip.sh
Created April 23, 2020 01:48 — forked from SunDi3yansyah/ip.sh
IP address
#!/bin/bash
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
@lifeofcoding
lifeofcoding / handler.js
Created September 4, 2019 11:28 — forked from jeffrafter/handler.js
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
qemu-img convert -O raw source.vhd output.raw
@lifeofcoding
lifeofcoding / create-react-app-on-heroku.sh
Created May 6, 2019 04:59 — forked from hackur/create-react-app-on-heroku.sh
Create a React app & deploy to Heroku
## Global install of the app generator
npm install -g create-react-app
## Setup the app (first-time only)
create-react-app my-app
cd my-app
git init
# Create the Heroku app; requires free account at https://www.heroku.com/
heroku create -b https://github.com/heroku/heroku-buildpack-static.git
@lifeofcoding
lifeofcoding / gist:22fba9e64fb181251a6e884ac9b30045
Created January 16, 2019 05:01 — forked from axefrog/gist:3353609
Node.js HTTP/HTTPS double forward proxy with two-stage authorization
/*
HTTP/HTTPS Forward Proxy
------------------------
The purpose of this proxy is to manage a set of third party proxies
internally, routing incoming requests through those proxies and
rotating which remote proxies are in use periodically as requests come
through, and without exposing the proxy credentials to the originating
client. Rate limiting will later be implemented internally so that if
the remote proxies have all been utilised too heavily, a "rate limit
exceeded" message will be returned to the client.
@lifeofcoding
lifeofcoding / api.proxy.server.js
Created January 16, 2019 05:01 — forked from davemo/api.proxy.server.js
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
#!/bin/bash
# ==============================================================
# CPU limit daemon - set PID's max. percentage CPU consumptions
# ==============================================================
# Variables
CPU_LIMIT=20 # Maximum percentage CPU consumption by each PID
DAEMON_INTERVAL=3 # Daemon check interval in seconds
BLACK_PROCESSES_LIST= # Limit only processes defined in this variable. If variable is empty (default) all violating processes are limited.
WHITE_PROCESSES_LIST= # Limit all processes except processes defined in this variable. If variable is empty (default) all violating processes are limited.