Skip to content

Instantly share code, notes, and snippets.

@chilismaug
chilismaug / main.js
Created July 9, 2016 02:48
improved main for kyle's multi-window electron youtute - he has app.js and main.js reversed as to std electron style
var remote = require('remote')
var ipc = require('ipc')
var Menu = remote.require('menu')
var menu = Menu.buildFromTemplate([
{
label: 'Electron',
submenu: [
@chilismaug
chilismaug / forfile-in-grep-echo.sh
Last active July 9, 2016 17:18
bash files loop example
#!/bin/bash
for file in /etc/*
do
if [ "${file}" == "/etc/resolv.conf" ]
then
countNameservers=$(grep -c nameserver /etc/resolv.conf)
echo "Total ${countNameservers} nameservers defined in ${file}"
break
fi
done
@chilismaug
chilismaug / bash file rename
Last active July 10, 2016 03:00
bash to rename files with sequential numbers
//Beauty in one line
ls | cat -n | while read n f; do mv "$f" "$n.extension"; done
change extension with desired PNG, Jpg or some-other.
//Try to use a loop, let, and printf for the padding:
@chilismaug
chilismaug / prepend
Created July 10, 2016 20:35
bash prepend a header file into a file
assuming that the file you want to edit is my.txt
$cat my.txt
this is the regular file
And the file you want to prepend is header
$ cat header
this is the header
Be sure to have a final blank line in the header file.
Now you can prepend it with
@chilismaug
chilismaug / app.py
Created March 13, 2018 18:15 — forked from debuggerboy/app.py
Simple Flask-couchdb demo
import simplejson
from flask import Flask, g, request
from couchdb.design import ViewDefinition
import flaskext.couchdb
app = Flask(__name__)
"""
CouchDB permanent view
@chilismaug
chilismaug / flaskr.py
Created August 6, 2018 18:22 — forked from webwurst/flaskr.py
This is the Flaskr-Tutorial using CouchDB instead of sqlite. For the original Tutorial see http://flask.pocoo.org/docs/tutorial/.
# -*- coding: utf-8 -*-
"""
Flaskr
~~~~~~
A microblog example application written as Flask tutorial with
Flask and couchdbkit.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
@chilismaug
chilismaug / mongshl-show-dbs.js
Last active August 23, 2018 17:35
Common first experiment in mongo shell is saying "show dbs" to see list of databases on the current server. But how to do in a mongo js shell script?
print("let's try 'listDatabases'");
dblist = JSON.stringify( db.adminCommand('listDatabases'), undefined, 2);
// stringify options 2 & 3 add pretty-like spaces
print(dblist) ;
@chilismaug
chilismaug / sts-REST-gs-projects-cors-vs-plain.md
Last active January 23, 2019 01:37
Spring getting started REST guides - compare parts of plain REST service guide with CORS flavored, more complete guide

STS gs Guides REST projects - Compare CORS vs plain

step REST gsg: CORS w/jQy client REST gsg: plain json
1 Create Resource Representation Class:
Greeting.java - POJO plus no arg constructor
Create Resource Representation Class:
Greeting.java- just a POJO
2 Create Resource Controller: GreetingController.java
- imports GetMapping , a shortcut for RequestMapping
- imports CrossOrigin
Create Resource Controller: GreetingController.java
- imports RequestMapping
3 /greeting route is mapped /greeting route is mapped
4 use @RestController annotation and default to using the Jackson Json converter use @RestController annotation and default to using the Jackson Json converter
5 add @CrossOrigin annotation above @Getmapping --
@chilismaug
chilismaug / wordcount.py
Created April 1, 2019 19:34
py word count
fruit = ['apple', 'avocado', 'orange', 'kiwi', 'grape', 'pineapple', 'raspberry', 'bluet', 'pineapple', 'raspberry',
'avocado', 'orange', 'kiwi', 'grape','apple', 'avocado', 'orange', 'kiwi', 'grape', 'pineapple']
def analyze_list(l):
counts = {}
for item in l:
if item in counts:
counts[item = counts[item] + 1
else:
@chilismaug
chilismaug / vba-fu-factors.md
Created May 7, 2019 13:44
VBA integrations (other apps) touched on @ 53

BAE Detica Document Direct Blue Zone - Rocket Datawatch Monarch SAS IE web scrappy scrape tools