Skip to content

Instantly share code, notes, and snippets.

🏐
Focusing

Operations Research Engineering Software+ ORESoftware

🏐
Focusing
Block or report user

Report or block ORESoftware

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ORESoftware
ORESoftware / spread.js
Created Jun 25, 2019
spread operator to merge / mixin objects
View spread.js
const a = {
a: {
b: {
c: 4,
d: 'str'
}
}
};
@ORESoftware
ORESoftware / jq-fail.sh
Created Jun 5, 2019
JQ does not make it easy to sanitize strings for JSON inclusion
View jq-fail.sh
#!/bin/bash
hist='sed '0,1d' "$HOME/my_bash_history" | wc -l' ### <<< we have some double quotes to escape
data="$( jq -nc --arg str "$hist" '{"attr": $str}' )"
echo "data: $data"
hist="$(echo "$data" | jq -r '.attr')"
echo "hist: $hist" # damnit it's back to where it was before
@ORESoftware
ORESoftware / cleanup.md
Last active May 28, 2019
Cleanup docker artifacts/items
View cleanup.md

Clean up docker images/containers/volumes/networks

#!/usr/bin/env bash


set +e;
@ORESoftware
ORESoftware / push.md
Created May 21, 2019
push event payload from Bitbucket API
View push.md

Here is a sample push payload from bitbucket API:

{
    "push": {
      "changes": [
        {
          "forced": false,
          "old": {
@ORESoftware
ORESoftware / git.commits.md
Created May 18, 2019
Removing old unneeded commits - saving disk space and making git clones faster
View git.commits.md

Say my git repo has 5,000 commits, how can I remove the first 4,000 commits that are quite old and no longer needed, in order to save disk space?

by Sebass van Boxel, Solutions Engineer at GitHub (2018-present)

First of all, I would try less destructive ways to clean up disk space in your git project. If you're collaborating on a repository with others, it's considered a bad practice to rewrite published history. If you’ve already decided that this is what you want to do, please skip the first part. One of the great powers of Git is that it preserves all history. Often you only realize that you really needed that history when it isn’t there anymore. For new people that join your project, it can be of great value to know what happened for what reason, by “removing” those old commits, they'll lose that context. My advice, before anything else, would be to run Git’s built-in housekeeping task:

@ORESoftware
ORESoftware / promises-in-series.js
Last active May 7, 2019
Run promises in series with an initial value
View promises-in-series.js
// promises are wrapped in a function - known as "promise-providers"
const providers = [
function(v){
return Promise.resolve(v+1);
},
function(v){
@ORESoftware
ORESoftware / my.Dockerfile
Created May 3, 2019
caching steps using git pull
View my.Dockerfile
RUN git clone x
ARG CACHEBUST=1
RUN git pull
RUN npm install
# the problem is that npm install will always run
# but we can do this instead
@ORESoftware
ORESoftware / apache.conf
Created Apr 30, 2019
Default apache conf contents
View apache.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
@ORESoftware
ORESoftware / bfs.js
Last active Apr 12, 2019
Simple breadth first traversal example
View bfs.js
'use strict';
const queue = [];
const root = {};
const main = {
name: 'main',
linkedSet:{
a: {
name: 'a',
@ORESoftware
ORESoftware / client.md
Last active Mar 19, 2019
Python swallows an error
View client.md

Run this container (it's a server):

docker run -p 6970:6970 -it oresoftware/live-mutex-broker:latest

then run this python script with Python 3.6.7:

You can’t perform that action at this time.