Skip to content

Instantly share code, notes, and snippets.

View jjhesk's full-sized avatar
🌸
focusing on DRL

SodiDav jjhesk

🌸
focusing on DRL
  • ZZY
  • 1601 McCarthy Blvd, Milpitas, CA 95035, US
View GitHub Profile
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

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,
@henryyan
henryyan / Convert16UnicodeToUTF8.java
Created August 30, 2013 16:11
转换16禁止的Unicode编码为UTF-8中文
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 {
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
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>
@JvmName
JvmName / Android CI
Created October 28, 2014 23:57
Android CI
#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:
@polbins
polbins / README.md
Last active September 6, 2019 11:08
Android Response Caching using Retrofit 1.9 + OkHttp 2.2

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

@bittner
bittner / 60-jetbrains.conf
Created September 25, 2015 07:57
Inotify configuration for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm). Create this file with e.g. `sudo vim /etc/sysctl.d/60-jetbrains.conf`
# 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
@fredhsu
fredhsu / ubuntudocker.sh
Last active September 6, 2024 10:15
Shell script to install Docker CE on ubuntu and post-install user configuration
#!/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 \
@4Kaylum
4Kaylum / provablyfair.py
Last active March 4, 2022 02:16
Implementation of the Primedice provably fair algorithm (https://dicesites.com/primedice/verifier)
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):
@timetocode
timetocode / instance.js
Created October 17, 2018 01:00
Example of using tls-json + express to create a master server listing service. master.js uses tls-json to listen over tls and accept connections + listing data from other services that connect, meanwhile instance.js shows a snippet of a game server that is listing itself on the master server. server.json is an example of what the http call to th…
// 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