Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from the game instance | |
const master = new TLSClient({ | |
options: { | |
ca: fs.readFileSync(config.API_CERT), | |
}, | |
reconnectInterval: 2000, | |
host: config.MASTER_API_HOST, | |
port: config.MASTER_API_PORT, | |
password: config.API_PASSWORD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import secrets | |
import hashlib | |
import hmac | |
class ProvablyFair(random.Random): | |
"""An object that represents a provably fair algorithm""" | |
def __init__(self, client_seed:str=None, *, server_seed:str=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 0EBFCD88 | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set inotify watch limit high enough for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm). | |
# Create this file as /etc/sysctl.d/60-jetbrains.conf (Debian, Ubuntu), and | |
# run `sudo service procps start` or reboot. | |
# Source: https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit | |
# | |
# More information resources: | |
# -$ man inotify # manpage | |
# -$ man sysctl.conf # manpage | |
# -$ cat /proc/sys/fs/inotify/max_user_watches # print current value in use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Android and CI and Gradle (A How-To) | |
There are tech stacks in this world that make it dead simple to integrate a <abbr title="Continuous Integration">CI</abbr> build system. <br> | |
The Android platform is not one of them. | |
Although Gradle is getting better, it's still a bit non-deterministic, and some of the fixes you'll need will start to feel more like black magic than any sort of programming. | |
But fear not! It can be done! | |
Before we embark on our journey, you'll need a few things to run locally: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.auto.value.AutoValue; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.Target; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
/** | |
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
* <p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.UnsupportedEncodingException; | |
import java.util.Scanner; | |
import org.apache.commons.lang.StringUtils; | |
/** | |
* @author: Henry Yan | |
*/ | |
public class Convert16UnicodeToUTF8 { | |
public static void main(String[] args) throws UnsupportedEncodingException { |
Note: This was written using elasticsearch 0.9.
Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:
$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
"_id": 1,