Skip to content

Instantly share code, notes, and snippets.

View jeanbza's full-sized avatar
🐘

Jean Barkhuysen jeanbza

🐘
View GitHub Profile
@jeanbza
jeanbza / php_inconsistency.php
Created May 27, 2015 00:22
Stuff in php I don't miss
<?php
$myArr = array_push($myArr, $someElem);
// Doesn't work. What?
array_push($myArr, $someElem);
// Works...ok... fine.
@jeanbza
jeanbza / converter.md
Last active August 29, 2015 14:22
Converter example
  1. Unzip members.sql
  2. mysql -uroot -e 'create database converter'
  3. mysql -uroot --database converter -e 'source members.sql'
  4. mysql -uroot -e 'select id, parent_id from converter.members' > boom.sql
  5. go run main.go raw_node.go linked_node.go --input boom.sql --output bam.sql --regex '(\d+)\t(\d+)' --target 'converter.members' --leftName lft --rightName rght
  6. mysql -uroot --database converter -e 'source bam.sql'
  7. Fire up xampp
  8. Make sure database is pointing to right place
  9. Point tree and accordion to root (id=1000)
  10. Navigate to http://localhost/sqltree/example_usage_php/accordion.php
@jeanbza
jeanbza / pez_startup.md
Last active August 29, 2015 14:24
Getting started with cloudfoundry HeritageCF

Notes:

HeritageCF = heritage in the sense of every pivot's right to CF

PEZ = pivotal elastic zones

Elastic zone = You can also use Elastic IP addresses to mask the failure of an instance in one Availability Zone by rapidly remapping the address to an instance in another Availability Zone.

Static app

@jeanbza
jeanbza / cf_failure.md
Created July 17, 2015 01:15
cf failure
 Thu Jul 16 2015 19:14:35 GMT-0600 (MDT) [DEA] OUT Starting app instance (index 0) with guid 55966ce0-56b0-4418-9b03-00fd49ba2883��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -> 0.0268s��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -- create_table(:matches)��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT == 20150714182755 AddMatchesAndClubs: migrating ===============================��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -- create_table(:clubs)��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -> 0.0221s��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -> 0.0223s��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -- add_reference(:matches, :clubs, {:index=>true, :foreign_key=>true})��
Thu Jul 16 2015 19:14:43 GMT-0600 (MDT) [App/0] OUT -- add_index(:clubs, [:name], {:unique=>true})��
@jeanbza
jeanbza / province_names.md
Last active August 29, 2015 14:26
Country names for provinces

Work in progress.

(according to wikipedia! - note that wiki seems to favor province a large amount of the time)

Province

  • Canada
  • South Africa
  • China
  • Portugal
@jeanbza
jeanbza / predicates_with_varargs.java
Created October 2, 2015 04:18
Predicates with varargs in java
public static <X> List<X> filterWithVarargPredicates(
List<X> allProducts,
Predicate<X>... predicates
) {
for (Predicate<X> predicate : predicates) {
allProducts = allProducts.stream()
.filter(predicate)
.collect(toList());
}
@jeanbza
jeanbza / download_google_fonts.rb
Created November 14, 2015 03:17
Downloading google fonts is easy, right? NOPE
require 'httparty'
woffPattern = /url\((.+)\.woff2/
fontFamilyPattern = /font-family: '(.+)'/
fontStylePattern = /font-style: (.+);/
fontWeightPattern = /font-weight: (.+);/
fileContents = ''
File.open('boom.css', 'r') do |f|
f.each_line do |line|
@jeanbza
jeanbza / telecom.php
Created March 14, 2016 12:41
telecom example
$email = '[email protected]'
$password = 'whatever'
$cell = '123456789'
// etc
$message = "
<MMS_message>
<LoginEmail>{$email}</LoginEmail>
<Password>${password}</Password>
<CellNumber>${cell}</CellNumber>
<Subject>{//etc}</Subject>
@jeanbza
jeanbza / sum_pending.js
Created June 4, 2016 20:48
Chase sum pending
var amounts = $("#Pending").find("td.amount");
var total = 0;
for (i = 0; i < amounts.length; i++) { total += parseFloat($(amounts[i]).text().substring(1)) }
@jeanbza
jeanbza / thrifty_traveler.sh
Created July 19, 2016 14:37
thrifty traveler parser
curl http://www.thriftytraveler.com/ | grep -A1 post-title | grep "a href" | perl -n -e'/title="(.+)"/ && print "$1\n"'