Skip to content

Instantly share code, notes, and snippets.

View stewones's full-sized avatar
🐠
Cooking something new.

Stewan stewones

🐠
Cooking something new.
View GitHub Profile
// your backend receives the orderId via POST/GET or whatever
// process it and returns something
{
response_or_anything: 'Thanks your order is on the way.'
}
@stewones
stewones / git-reset-author.sh
Created October 15, 2021 01:09 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@stewones
stewones / mongo.sh
Last active March 4, 2020 03:21
install mongodb ubuntu
#!/bin/bash
# GET ALL USER INPUT
echo "super password"
read SUPER_PW
echo "api password"
read API_PW
tput setaf 2; echo 'Wellcome to mongodb install bash script';
sleep 2;
tput sgr0
@stewones
stewones / blob-util.min.js
Created February 14, 2020 21:00 — forked from nolanlawson/blob-util.min.js
Read img tag, store it as a blob, then read it as a blob
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.blobUtil=e():"undefined"!=typeof global?global.blobUtil=e():"undefined"!=typeof self&&(self.blobUtil=e())}(function(){return function e(t,n,r){function o(u,a){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t){"use strict";function n(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=-1;++o<t;)r[o]=e.charCodeAt(o);return n}function r(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=-1;++o<r;)t+=String.fromCharCode(n[o]);return t}function o(e,t){return new L(function(n,r){var o=new Image;t&&(o.crossOrigin=t),o.onload=function(
@stewones
stewones / nginxproxy.md
Created December 6, 2019 01:23 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@stewones
stewones / test.ts
Last active December 4, 2019 15:13
.on test
ngOnInit() {
collection(`cats`)
.where('chat_room.id', '==', '2a4b86fc')
.where('created_at_timestamp', '>', 101)
.on()
.subscribe(
data => console.log('message received:', data),
error => console.log(error)
);
}
@stewones
stewones / nginx.conf
Created April 2, 2019 15:46
elasticsearch config for nginx (say no to x-pack)
events {
worker_connections 1024;
}
http {
upstream elasticsearch {
server 127.0.0.1:9200;
keepalive 15;
@stewones
stewones / elasticsearch-docker-script
Created July 9, 2018 21:39 — forked from mschoch/elasticsearch-docker-script
A script to fix ownership of Elasticsearch data directory (when mounted as a volume in docker), then switch to elasticsearch user and launch elasticsearch
#!/bin/sh
# fix permissions (wrong if docker mounted volume)
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
# now switch to elasticsearch user and run in foreground
echo Starting: /usr/share/elasticsearch/bin/elasticsearch -Des.default.config=$CONF_FILE -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=$LOG_DIR -Des.default.path.data=/var/lib/elasticsearch -Des.default.path.work=/tmp/elasticsearch -Des.default.path.conf=$CONF_DIR $@
su elasticsearch -s /bin/sh -c "/usr/share/elasticsearch/bin/elasticsearch -Des.default.config=$CONF_FILE -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=$LOG_DIR -Des.default.path.data=/var/lib/elasticsearch -Des.default.path.work=/tmp/elasticsearch -Des.default.path.conf=$CONF_DIR $@"
import { getVersion } from "../../../src/libs/version";
describe('getVersion', () => {
let short, full;
beforeEach(() => {
short = getVersion(1054);
full = getVersion(1054, true);
})
it('should format the short version', (() => {
expect(short).toBe('1.0.5');
@stewones
stewones / app.component.spec.ts
Created July 4, 2018 21:23
app component test
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { MaterialModule } from './modules/material/material.module';
import { ComponentsModule } from './components/components.module';
import { AppRoutesModule } from './app.routes';
import { APP_BASE_HREF } from '@angular/common';
import { BotServiceModule, BotService } from './services/bot.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { PipesModule } from './pipes/pipes.module';