Skip to content

Instantly share code, notes, and snippets.

View daluu's full-sized avatar

David Luu daluu

View GitHub Profile
@daluu
daluu / sendSmsToTextbelt.php
Last active October 5, 2016 22:58
Simple PHP curl demo for Textbelt
<?php
//This demo doesn't cover case of network connectivity issues (failure to send HTTP POST to Textbelt)
//One could just wrap the request around try/catch exception handling for that
//Move the demo function into a separate file to make this into a wrapper library you can require/include and then call from a script
// A simple wrapper function to send SMS via Textbelt using curl in PHP
function sendSmsToTextbelt($number, $message, $locale="USA"){
//determine the Textbelt URL to POST to...
@daluu
daluu / index.html
Last active November 22, 2017 22:50
Cumulative Histogram with CDF line
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
font: 10px sans-serif;
}
.bar rect {
fill: steelblue;
shape-rendering: crispEdges;
}
@daluu
daluu / read_apache_storm_config_and_bolt_init_and_process_sample.js
Last active October 31, 2018 06:12
Sample bolt showing how to initialize a bolt and read in Apache Storm topology configuration and process tuple in node.js and how to unit test it
#! /usr/bin/env node
'use strict';
var storm = require("pathTo/storm.js"); //the official storm multilang node client/binding from Apache Storm project
var BasicBolt = storm.BasicBolt;
TestBolt.prototype = Object.create(BasicBolt.prototype);
TestBolt.prototype.constructor = TestBolt;
function TestBolt() {
@daluu
daluu / additional_notes_on_js_async2sync.txt
Last active November 10, 2018 01:02
Dealing with return values for asynchronous calls in javascript (when you're accustomed to synchronous code)
https://blog.cloudboost.io/execute-asynchronous-tasks-in-series-942b74697f9c
https://blog.scottlogic.com/2017/09/14/asynchronous-recursion.html
@daluu
daluu / custom_rf_docker_image_notes.txt
Created April 7, 2019 22:01
Notes for building custom Robot Framework docker images
Below are various notes to help if building a custom RF docker image that we don't already have publicly available,
e.g. IronPython-based RF docker image, Java/Jython-based RF docker image.
java -jar jython_installer-<version>.jar
# Robot Framework 3.0 supports Jython 2.7 which requires Java 7 or newer.
jython -m ensurepip
jython -m pip install robotframework
@daluu
daluu / zkcheck.sh
Created October 24, 2019 16:21
zk status check
#!/bin/sh
# use either option below
echo ruok | nc zksvr 2181
echo srvr | nc zksvr 2181
@daluu
daluu / webhooks.txt
Created November 1, 2019 16:01
webhooks stuff
https://webhook.site
@daluu
daluu / py_env_notes.txt
Last active November 14, 2019 16:59
python env notes
various python related commands to run relating to envs
apt-get -y update && apt-get -y --force-yes --fix-missing install build-essential python-dev
pip install virtualenv
virtualenv --system-site-packages -p python3 venv3
source venv3/bin/activate
. venv3/bin/activate
@daluu
daluu / d3.legend.js
Last active March 10, 2020 20:58 — forked from bunkat/index.html
Sample trendline and linear, polynomial, exponential, logarithmic, and power regression analysis using regression.js
// d3.legend.js
// (C) 2012 ziggy.jonsson.nyc@gmail.com
// MIT licence
(function() {
d3.legend = function(g) {
g.each(function() {
var g= d3.select(this),
items = {},
svg = d3.select(g.property("nearestViewportElement")),
@daluu
daluu / FileDownloader.java
Last active November 19, 2020 10:17
A simple example of downloading file with Java outside of Selenium to workaround Selenium limitation in file downloads.
/* an example of file download in Java w/ minimal amount of code, library imports,
* and object instantiations especially if you wrap/encapsulate code like example below.
* NOTE: sample code has been tested to work but not thoroughly tested. Use at your own risk.
*/
import java.net.*;
import java.io.*;
//be sure to delete file after working with it. filenamePrefix ~ "test_", file extension ~ ".jpg", include the "."
public String downloadFile(String url, String filenamePrefix, String fileExtension) throws Exception{