Skip to content

Instantly share code, notes, and snippets.

View platy's full-sized avatar
🐟

Mike Bush platy

🐟
View GitHub Profile
@platy
platy / install.intl.sh
Last active August 29, 2015 14:01 — forked from royriojas/install.apc.sh
Modified from install.apc.sh for installing the INTL library
#!/bin/bash
echo '===> install intl.so in OSX Mavericks'
mkdir -p ~/tmp/intl-deps
# Compile PCRE - Perl Compatible Regular Expressions
cd ~/tmp/intl-deps
curl -O ftp://ftp.csx.cam.ac.uk//pub/software/programming/pcre/pcre-8.33.tar.gz
tar -xvzf pcre-8.33.tar.gz
#!/bin/bash
echo '===> install apc.so in OSX Mavericks'
mkdir -p ~/tmp/apc-deps
# Compile PCRE - Perl Compatible Regular Expressions
cd ~/tmp/apc-deps
curl -O ftp://ftp.csx.cam.ac.uk//pub/software/programming/pcre/pcre-8.33.tar.gz
tar -xvzf pcre-8.33.tar.gz
@platy
platy / ResourceCopy.scala
Created January 23, 2015 17:06
Recursively copy files from the classpath onto the filesystem. In scala
package amqptest
import java.io.{File, FileInputStream, FileOutputStream, InputStream}
import java.net.{JarURLConnection, URL}
import java.util.function.Consumer
import java.util.jar.{JarEntry, JarFile}
import sun.net.www.protocol.file.FileURLConnection
@platy
platy / ScheduledExecutor.scala
Created January 25, 2015 01:11
Scala wrapper around java's ScheduledExecutorService
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy
import java.util.concurrent._
import scala.concurrent.{ Promise, Future }
import scala.concurrent.duration.FiniteDuration
import scala.language.implicitConversions
import scala.util.Try
object ScheduledExecutor {
private val defaultHandler: RejectedExecutionHandler = new AbortPolicy
@platy
platy / hexStringToString.scala
Created June 26, 2015 10:24
String data converters
def hexStringToString(hexString: String) =
new String(hexString.grouped(2).map(byteAsString => Integer.parseInt(byteAsString, 16).toByte).toArray)
@platy
platy / gist:da45de1acc9ccba1c452
Last active August 29, 2015 14:24
Stupid html modal
<style>
#container {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
visibility: visible;
z-index: 1000;
display: table;
@platy
platy / README.md
Last active May 5, 2023 08:38 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@platy
platy / lifetime_shortened_by_newtype.rs
Created March 12, 2020 14:59
I was confused that the string slice retrieved from the struct was not allowed to outlive it. It was because I had put the same lifetime bound on the borrow of self as on the contained string
fn main() {
println!("{}", get_back_the_same_string("Hello World!"));
}
fn get_back_the_same_string<'a>(string: &'a str) -> &'a str {
let nt = NewType(string);
return nt.get_string()
}
struct NewType<'b>(&'b str);
@platy
platy / lifetime_shortened_by_mutability.rs
Created March 12, 2020 15:21
Remove the [mut] and it compiles, what is the difference?
fn main() {
let mut string = String::from("Hello World!");
println!("{}", get_back_the_same_string(string.as_mut_str()));
}
fn get_back_the_same_string<'a>(string: &'a mut str) -> &'a str {
let nt = NewType(string);
return nt.get_string()
}
@platy
platy / .sh
Created March 28, 2020 13:03
Ingress failing on transit-radar
# port forwarding works
% kubectl port-forward svc/transit-radar 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
Handling connection for 8080
# but using the ingress fails with 502, the ingress controller logs show it fails to connect to 192.168.99.20:80 (the pod IP)
% kubectl logs nginx-ingress-controller-np59k --tail=5
84.138.192.89 - - [28/Mar/2020:12:55:34 +0000] "POST /api HTTP/2.0" 200 16 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:74.0) Gecko/20100101 Firefox/74.0" 72 0.834 [default-earth-ratings-80] [] 192.168.99.12:80 16 0.836 200 06f0579ae0775d73858965b45eb32750
2020/03/28 12:56:00 [error] 5548#5548: *119748173 connect() failed (111: Connection refused) while connecting to upstream, client: 91.64.175.187, server: transit-radar.njk.onl, request: "GET / HTTP/2.0", upstream: "http://192.168.99.20:80/", host: "transit-radar.njk.onl"