Skip to content

Instantly share code, notes, and snippets.

@ryumei
ryumei / metadata.yaml
Created February 13, 2020 04:32
Tutorial metadata configuration yaml
architecture: "x86_64"
creation_date: 1581238800
properties:
architecture: "x86_64"
description: "Debian Unstable (sid) with preinstalled Splunk Enterprise v8.0.2"
os: "debian"
release: "sid"
@ryumei
ryumei / req-rdap.ps1
Last active January 23, 2020 06:27
Look up RDAP information listed in a input file
Get-Content input.txt | Foreach-Object {
$item = invoke-webrequest https://www.rdap.net/ip/$_ | convertfrom-json;
$item | Add-Member -MemberType NoteProperty -Name "ipaddr" -Value "$_";
$item.PSObject.Properties.Remove("entities");
$item.PSObject.Properties.Remove("links");
$item.PSObject.Properties.Remove("notices");
$item | convertto-json;
}
@ryumei
ryumei / props.conf
Created December 11, 2019 01:48
Sample of Splunk props.conf for Tab-separated file without header.
[ tsv_custom ]
CHARSET=UTF-8
INDEXED_EXTRACTIONS=csv
KV_MODE=none
SHOULD_LINEMERGE=false
category=Structured
description=Tab-separated value format. Set header and other settings in "Delimited Settings"
disabled=false
pulldown_type=true
LINE_BREAKER=([\r\n]+)
@ryumei
ryumei / post_qiita.py
Created July 25, 2019 06:45
Post Qiita article via API
# -*- coding: utf-8 -*-
#
# Update an article via Qiita API
# Require: requests and toml (via pip)
#
import sys
import os
import logging
import json
import toml
@ryumei
ryumei / check_tmpfile.c
Created June 7, 2019 02:54
Sample of tmpfile()
#include <stdio.h>
int main(void) {
printf("%s\n", tmpfile());
return 0;
}
@ryumei
ryumei / GET with urllib2
Created August 15, 2018 07:34
GET HTTP with Python 2.7 standard lib
import urllib
import urllib2
import urlparse
import json
def get(url, headers=None, params=None):
if params is not None:
query = urllib.urlencode(params)
url = '%s?%s' % (url, query)
req = urllib2.Request(url, headers=headers)
@ryumei
ryumei / randomquote.sh
Created August 10, 2018 03:20
Get an oneline quote with timestamp
#!/bin/sh
API_URL="https://talaikis.com/api/quotes/random/"
curl -XGET "$API_URL" | sed -e "s/{/{\"timestamp\":`date '+%s'`,/"
@ryumei
ryumei / search_tweets.py
Created May 10, 2018 09:32
Sample of Twitter Standard Search API Python Requests
import requests
import os
apikey = os.environ['TWITTER_TOKEN']
BASE_URL = 'https://api.twitter.com/1.1/search/tweets.json'
def get_tweets(query, apikey, base_url=BASE_URL, next_results=None):
headers = {"Authorization": "Bearer {key}".format(key=apikey)}
if next_results is None:
url = base_url
params = {'q': query}
import requests
from requests.auth import HTTPBasicAuth
import urllib
class Twitter(object):
def _access_token(self, key, secret):
r = requests.post('https://api.twitter.com/oauth2/token',
auth=HTTPBasicAuth(key, secret),
headers={'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},
data={'grant_type':'client_credentials'})
@ryumei
ryumei / Makefile
Created January 16, 2017 06:48
sample of Makefile for go
NAME := my_go_program
VERSION := $(shell git describe --tags)
REVISION := $(shell git rev-parse --short HEAD)
SRCS := $(shell find . -type f -name '*.go')
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\""
all: bin/$(NAME) dist
bin/$(NAME): $(SRCS)