Skip to content

Instantly share code, notes, and snippets.

View menicosia's full-sized avatar

Marco Nicosia menicosia

View GitHub Profile
@menicosia
menicosia / choose-word.py
Created December 13, 2020 03:42
Finding a random word using Python
>>> import re
>>> import random
>>> import time
>>> random.seed(time.time())
>>> wordHandle = open("/usr/share/dict/web2")
>>> words = wordHandle.readlines()
>>> aFilter = re.compile("^[Aa]")
>>> wordsWithA = list(filter(aFilter.match, words))
>>> len(wordsWithA)
17096
$ cat classScope.js
"use strict" ;
class classScope {
constructor(item) {
var self = this ;
self._item = item ;
}
lexicalMethod() {
var mysql = require('mysql') ;
var dbClient = undefined ;
var db_uri = "mysql://clickpoint:password@127.0.0.1/clickpoint" ;
var schema = {
redirects : "(id int AUTO_INCREMENT, key VARCHAR(50), url VARCHAR(2048))",
clicks : "(ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, IP VARBINARY(16))"
} ;
function createOnEmpty(err, results, fields, tableName, create_def) {
var g = { a : 1, b : 2 }
function callBack (key, value) {
console.log("Callback called with key: " + key + "\nAnd value: " + value) ;
}
function doNothing (key, value, cb) {
true ;
console.log(key + ": doing nothing") ;
@menicosia
menicosia / sg-steps.md
Last active April 16, 2018 05:13
Steps to enable security groups on bosh-lite
  1. cf api https://api.[REPLACE-WITH-YOUR-HAPROXY-IP].xip.io --skip-ssl-validation
  2. cf auth [YOUR CF ADMIN USERNAME] [YOUR CF ADMIN PASSWORD]
  3. Create sg.json file with the following contents:
[
  {
  "protocol": "all",
  "destination": "10.244.4.0-10.254.0.0"
  }
]
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/usr/local/bin/npm',
npm verb cli '--loglevel',
npm verb cli 'verbose',
npm verb cli 'install',
npm verb cli 'sleep' ]
npm info using npm@2.7.5
npm info using node@v0.12.2
npm verb node symlink /usr/local/bin/node
@menicosia
menicosia / cf-mysql-release v23 sample-aws-stub.yml
Created July 25, 2015 05:12
Early Release of sample-aws-stub.yml from cf-mysql-release v23
director_uuid: REPLACE_WITH_YOUR_DIRECTOR_UUID
# NOTE:
# Replace 10.0.{0,1,2} part of the octet
# with your network configuration
networks:
- name: mysql1
type: manual
subnets:
- range: 10.10.32.0/24
VERSION:
6.10.0-b78bf10
REQUEST: [2015-07-16T15:35:27-07:00]
POST /oauth/token HTTP/1.1
Host: login.54.152.199.131.xip.io
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
ignores = (
{
level = "JOINS PARTS QUITS";
pattern = "tabloyd";
regexp = "yes";
channels = ( "#tc" );
},
{ level = "JOINS PARTS QUITS"; channels = ( "#ey-sa-alerts", "#engineyardops",
"#ey-alerts", "#ey-sysadmin", "#engineyard" ); }
);