Skip to content

Instantly share code, notes, and snippets.

View mnylen's full-sized avatar

Mikko Nylén mnylen

  • Mikko Nylén Oy
  • Toijala
  • X @nylemi
View GitHub Profile
wait4(-1, 0x7fffe0ce8fd4, WNOHANG|WSTOPPED|WCONTINUED, 0x7fffe0ce8ff0) = 0
rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call)
kill(8741, SIGCONT) = -1 ESRCH (No such process)
kill(8744, SIGCONT) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [INT CHLD WINCH], 8) = 0
rt_sigsuspend([], 8) = ? ERESTARTNOHAND (To be restarted if no handler)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED, si_pid=8744, si_uid=1000, si_status=SIGCONT, si_utime=0, si_stime=0} ---
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [CHLD], 8) = 0
rt_sigprocmask(SIG_SETMASK, [CHLD], ~[KILL STOP RTMIN RT_1], 8) = 0
wait4(-1, [{WIFCONTINUED(s)}], WNOHANG|WSTOPPED|WCONTINUED, {ru_utime={tv_sec=0, tv_usec=0}, ru_stime={tv_sec=0, tv_usec=15625}, ...}) = 8744
@mnylen
mnylen / docker-login.sh
Last active September 13, 2018 06:07
Get JWT token to access private repositories on hub.docker.com
function echoerr {
echo "$@" 1>&2;
}
docker_username=${DOCKER_USER:-}
docker_password=${DOCKER_PASSWORD:-}
if [ -z "$docker_username" ]; then
if command -v docker-credential-osxkeychain > /dev/null 2>&1; then
readonly registry_url="https://index.docker.io/v1/"

S3/CloudFront problems

  • CloudFront: updates are very slow, taking about 20 - 30 minutes each time you try to change something to fix some of the things listed here
  • CloudFront: no support for Cache-Control: stale-while-revalidate (would be nice for index.html etc. that can't be hashed)
  • CloudFront: does not forward the original host name to a custom origin (would be useful for creating a S3 proxy origin to fix some of the issues here, instead of trying to implement them w/ lambda@edge)
  • S3: Vary: Origin header is not added for non-CORS requests    * this is needed to fix a browser caching issue where if you load an image via , the browser will cache the response to that. Then, when you do cross origin XHR to the same object to receive metadata, the browsers will use the cached response and fail, because it didn't contain Access-Control-Allow-Origin header for the original request made by - and because there was no Vary: Origin, browser doesn't think it could get a di
@mnylen
mnylen / checklist.md
Last active September 20, 2015 20:19
Checklist to get ElasticSearch cluster on AWS EC2 working

Checklist to get ElasticSearch cluster on AWS EC2 working

  • Install cloud-aws-plugin (https://github.com/elastic/elasticsearch-cloud-aws)

  • Give your EC2 instances IAM Instance Policy with permission to ec2:DescribeInstances. The plugin will automatically get correct access keys after this.

    • You should really do the above, but you can also just create a new IAM user and set up cloud.aws.access_key and cloud.aws.secret_key in elasticsearch.yml. But you really should create instance policy instead.
  • Set discovery.type: ec2 in elasticsearch.yml

@mnylen
mnylen / _.md
Last active April 23, 2021 21:17
Debounced fetching to reduce number of requests when doing API proxying through GraphQL

Simple implementation of debounced fetching in GraphQL to allow merging of multiple rest / database requests into one. Although this example uses GraphQL, the debouncedFetch / fetchProgramPlaycount implementations could probably be used in any context to achieve the same result.

This approach was first described by @leebyron at graphql/graphql-js#19 (comment)

For example this allows turning ten requests for playcounts from this GraphQL query into just one:

{
  latestPrograms(first: 10) {
    name,

playcount

@mnylen
mnylen / gist:8c4010ab353f4886f89c
Last active March 12, 2021 16:33
Using the new Safari View Controller from React Native application

Using the new Safari View Controller from React Native application

  • Safari View Controller is iOS 9 only. You need Xcode 7 (beta 2 currently) to use it

  • React Native 0.6.0 is the minimum I got this working on

You might need to add this to your Info.plist in order for iOS 9 to load your application correctly:

<key>NSAppTransportSecurity</key>
# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \
use std::io::BufferedReader;
use std::io;
fn main() {
let mut reader = BufferedReader::new(io::stdin());
println!("What is your name?");
let age_input: ~str = reader.read_line().unwrap();
let age_trimmed: &str = age_input.trim();
import org.scalatra._
import org.scalatra.test.specs2._
class TestTest extends MutableScalatraSpec {
override def start() {
println("/// STARTING JETTY")
super.start()
}
override def stop() {
$ m2search "logback"
"de.huxhorn.lilith" % "logback" % "0.9.41"
"ch.qos.logback" % "logback" % "0.5"
"ch.qos.logback" % "logback-parent" % "1.0.6"
"ch.qos.logback" % "logback-site" % "1.0.6"
"ch.qos.logback" % "logback-skin" % "0.9"
"org.wicketstuff" % "wicketstuff-logback-parent" % "6.0.0-beta1.1"
"ch.qos.logback" % "audit-parent" % "0.5"
"ch.qos.logback" % "logback-examples" % "1.0.6"
"ch.qos.logback" % "logback-access" % "1.0.6"