Skip to content

Instantly share code, notes, and snippets.

@thompsongl
thompsongl / enum.table.plugin.jsx
Created November 20, 2017 16:11
Customizing swagger-ui via plugins
import React from 'react';
import PropTypes from 'prop-types';
class EnumTable extends React.Component {
render() {
const {propVal} = this.props;
return (
<table className="c-codeTable">
<thead>
<tr><th>Code</th><th>Value</th><th>Description</th></tr>
@vipulshah2010
vipulshah2010 / RetrofitException.java
Created June 6, 2016 05:39
RxAndroid Error Handling
public class RetrofitException extends RuntimeException {
public static RetrofitException httpError(String url, Response response, Retrofit retrofit) {
String message = response.code() + " " + response.message();
return new RetrofitException(message, url, response, Kind.HTTP, null, retrofit);
}
public static RetrofitException networkError(IOException exception) {
return new RetrofitException(exception.getMessage(), null, null, Kind.NETWORK, exception, null);
}
@chrisdubois
chrisdubois / submission.py
Created March 23, 2015 17:19
Starter code for Otto Group Product Classification
import graphlab as gl
import math
import random
train = gl.SFrame.read_csv('data/train.csv')
test = gl.SFrame.read_csv('data/test.csv')
del train['id']
def make_submission(m, test, filename):
preds = m.predict_topk(test, output_type='probability', k=9)
@a613
a613 / LocaleSwitchActivity.java
Last active September 14, 2022 08:13
Android activity that uses a custom locale for its duration
public class LocaleSwitchActivity extends Activity {
private static final String LOG_TAG = LocaleSwitchActivity.class.getSimpleName();
private static final String LOCALE_EXTRA = "locale";
private Locale customLocale;
private boolean restartingForLocaleChangeFlag;
protected void useLocale(Locale locale) {
Intent intent = getIntent();
@unbracketed
unbracketed / export_repo_issues_to_csv.py
Last active August 3, 2023 18:13
Export Issues from Github repo to CSV (API v3)
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
"""
import csv
import requests
@turtlesoupy
turtlesoupy / nginx.conf
Created July 8, 2012 21:16
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@patrickmn
patrickmn / observer.go
Created January 2, 2012 09:12
Go observer pattern example
package main
import (
"fmt"
"sync"
"time"
)
var wg *sync.WaitGroup