Skip to content

Instantly share code, notes, and snippets.

View eagletmt's full-sized avatar

Kohei Suzuki eagletmt

View GitHub Profile
@eagletmt
eagletmt / main.go
Last active October 28, 2023 00:02
List installable Android SDK packages (similar to sdkmanager --verbose --list)
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@eagletmt
eagletmt / tombloo.service.extractors.Danbooru.js
Created December 23, 2011 13:44
Tombloo extractor for Danbooru
(function() {
Tombloo.Service.extractors.register({
name : 'Photo - Danbooru',
ICON : 'http://danbooru.donmai.us/favicon.ico',
URL : 'http://danbooru.donmai.us/',
check : function(ctx) {
const DANBOORU_LIKE_SITES = [
'://danbooru.donmai.us/post/show/',
'://yande.re/post/show/',
'://konachan.com/post/show/',
@eagletmt
eagletmt / main.rs
Created February 13, 2022 10:45
Deserializing multiple (and optional) internally tagged values
fn main() {
for j in [
r#"{"type": "foo", "subtype": "bar", "a": 1}"#, // Deserialize to Foo(Bar(...))
r#"{"type": "foo", "subtype": "baz", "b": "1"}"#, // Deserialize to Foo(Baz(...))
r#"{"type": "foo", "c": true}"#, // Deserialize to Foo(Qux(...))
r#"{"type": "foo", "subtype": "other", "c": true}"#, // Error
r#"{"type": "hoge", "subtype": "fuga", "d": 2}"#, // Deserialize to Hoge(Fuga(...))
r#"{"type": "hoge", "subtype": "piyo", "e": 3}"#, // Deserialize to Hoge(Piyo(...))
] {
let s = serde_json::from_str::<S>(j);
std.join(' + ', [std.format('{ xs+: [%d] }', i) for i in std.range(0, 10000)])
% psql -c 'create table t (x integer not null)'
CREATE TABLE
% psql -c 'insert into t (x) values (0)'
INSERT 0 1
% psql -c 'select * from t'
 x
---
 0
(1 row)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <assert.h>
void *find_function(char *obj, const char *name);
int main(void)
@eagletmt
eagletmt / input.json
Created April 13, 2020 13:30
How to deserialize internally tagged JSON in Go?
{
"items": [
{"type": "A", "foo": "bar"},
{"type": "B", "hoge": "fuga"}
]
}
use rayon::prelude::*;
fn main() {
std::thread_local!(static CLIENT: std::cell::RefCell<Option<reqwest::Client>> = std::cell::RefCell::new(None));
rayon::ThreadPoolBuilder::new()
.num_threads(8)
.build_scoped(
|thread| {
CLIENT.with(|c| {
*c.borrow_mut() = Some(reqwest::Client::new());
extern crate env_logger;
extern crate rusoto_ec2;
fn main() {
use rusoto_ec2::Ec2;
env_logger::init();
// my VPC case in ap-northeast-1 region
let image_id = "ami-7a1be605";
function! s:encodeURIComponent(str)
let s = ''
for i in range(strlen(a:str))
let c = a:str[i]
if c =~# "[A-Za-z0-9-_.!~*'()]"
let s .= c
else
let s .= printf('%%%02X', char2nr(a:str[i]))
endif
endfor