An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| /* | |
| * Copyright 2012 CodeSlap - Cristian Castiblanco | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| public class MyContentProvider extends ContentProvider { | |
| private final ThreadLocal<Boolean> mApplyingBatch; | |
| private final ThreadLocal<Set<Uri>> mChangedUris; | |
| private boolean applyingBatch() { | |
| return mApplyingBatch.get() != null && mApplyingBatch.get(); | |
| } | |
| private Uri insert(final Uri uri, final ContentValues values, final SQLiteDatabase db) { | |
| // do the uri matching and insert |
| ### Nginx upstart script | |
| ### source: http://serverfault.com/a/391737/70451 | |
| ### /etc/init/nginx.conf | |
| description "nginx http daemon" | |
| start on (filesystem and net-device-up IFACE=lo) | |
| stop on runlevel [!2345] | |
| env DAEMON=/opt/nginx/sbin/nginx |
| global | |
| log 127.0.0.1 local0 | |
| log 127.0.0.1 local1 notice | |
| maxconn 4096 | |
| nbproc 1 | |
| pidfile /var/run/haproxy.pid | |
| user haproxy | |
| group haproxy |
| // Pseudo code (Not for production) | |
| $link_regex = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/g" | |
| preg_match_all($link_regex, $your_paragrah, $links_array) | |
| // loop through links array and use the following code to parse url and variable | |
| parse_str(parse_url( $url, PHP_URL_QUERY ), $vars ); | |
| echo $vars['v']; |
| package com.squareup.example; | |
| public abstract BaseActivity extends SherlockActivity { | |
| private final ScopedBus scopedBus = new ScopedBus(); | |
| protected ScopedBus getBus() { | |
| return scopedBus; | |
| } | |
| @Override public void onPause() { |
| import com.android.volley.toolbox.HurlStack; | |
| import com.squareup.okhttp.OkHttpClient; | |
| import java.io.IOException; | |
| import java.net.HttpURLConnection; | |
| import java.net.URL; | |
| /** | |
| * An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which | |
| * uses OkHttp as its transport. | |
| */ |
| // Provided by Square under the Apache License | |
| public final enum BusProvider { | |
| INSTANCE; | |
| public static final Bus BUS; | |
| private BusProvider() { | |
| BUS = new Bus(); | |
| } | |
| } |
An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| #don't send the nginx version number in error pages and Server header | |
| server_tokens off; | |
| # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security | |
| # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping | |
| add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; | |
| # config to don't allow the browser to render the page inside an frame or iframe | |
| # and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking | |
| # if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri |