Skip to content

Instantly share code, notes, and snippets.

View shinshin86's full-sized avatar
👶

Yuki Shindo shinshin86

👶
View GitHub Profile
@shinshin86
shinshin86 / pocket_exportdata_to_json.py
Last active May 14, 2018 06:37
Pocket export html convert to json
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import collections as cl
import json
"""
The export data is converted into json file of this structure.
///////////////
{
@shinshin86
shinshin86 / slack_files_delete.py
Created May 28, 2017 00:29
Script to delete files uploaded to Slack.
# This code is taken from these blog.
# https://www.shiftedup.com/2014/11/13/how-to-bulk-remove-files-from-slack
# http://qiita.com/sotayamashita/items/cb811f512162e61f56f4
#
# And I am changing the implementation a little.
# (It got to get arguments, and modify for Python 3)
import requests
import json
import calendar
@shinshin86
shinshin86 / mongo_data_to_data_frame.py
Created April 13, 2017 22:58
This is sample of mongo data to data frame
import pymongo
import json
import pandas as pd
from bson.json_util import dumps
def get_co():
client = pymongo.MongoClient(hostname, port) # hostname & port
db = client.dbname # db name
collection = db.collection_name # collection name
return collection
@shinshin86
shinshin86 / anonypost_bot_sample.js
Created April 2, 2017 22:33
This is a sample of slack bot for doing anonymous posting.
// Posting anonymously botn sample
// Confirm whether to submit a post => yes / no
controller.hears(['anonypost (.*)'], ['direct_message','direct_mention','mention'], function(bot,message) {
var matches = message.text.match(/anonypost (.*)/i);
var anonypost = matches[1];
bot.reply(message, 'I will post this content anonymously. Is it OK? => ' + anonypost );
bot.startConversation(message, function(err, convo) {
convo.ask('yes / no',
[
{
@shinshin86
shinshin86 / cf.go
Created January 14, 2017 00:02
"cf" display a color text of standard output.
// Usage:
// cf {color} {text}
// colors => black, red, green, yellow, blue, magenta, cyan, white
package main
import (
"fmt"
"flag"
)
@shinshin86
shinshin86 / setup_for_dev_ubuntu1604.sh
Created September 17, 2016 23:42
Setup for development environment(Ubuntu 16.04)
# setup_for_ubuntu_devmachine
#====================================================================
# Basic setting
#====================================================================
sudo apt-get update -y && sudo apt-get upgrade -y &&
env LANGUAGE=C LC_MESSAGES=C xdg-user-dirs-gtk-update
@shinshin86
shinshin86 / rehalf.py
Last active September 7, 2016 21:41
Image resize to half.
# -*-coding: utf-8-*-
import glob
import os
from PIL import Image;
# Get all of the image files that exist under the "work" directory.
file_list = [r.split('/')[-1] for r in glob.glob('./work/*')]
for f in file_list:
file_extension = os.path.splitext(f)
target_file_extension = [".jpeg", ".jpe", ".jpg", ".JPEG",".png",".PNG",".gif",".GIF",".bmp",".BMP"]
# Please use "copy and paste" at Your Python environment.
# I have been tested with Python3.
# Hello World
python -c "print('Hello World')"
# Create Files(Example: Create a 10 pcs "text" file)
python -c "import random;[open(str(random.randint(1, 100000)) +'.txt', 'w').close() for i in list(range(10))]"
# Rename a all file name in the directory("jpg"file)
import java.util.Random;
public class PasswordGenerate {
/**
* Password generate
*
* @param passLength
* Password length
* @return
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;