Skip to content

Instantly share code, notes, and snippets.

View GitHub30's full-sized avatar
🌴
On vacation

GitHub30

🌴
On vacation
  • Osaka, Japan
View GitHub Profile
@GitHub30
GitHub30 / get_random_bytes.js
Created May 8, 2023 10:55 — forked from alexdiliberto/get_random_bytes.js
Get random bytes in Javascript (Browser/Node)
let getRandomBytes = (
(typeof self !== 'undefined' && (self.crypto || self.msCrypto))
? function() { // Browsers
var crypto = (self.crypto || self.msCrypto), QUOTA = 65536;
return function(n) {
var a = new Uint8Array(n);
for (var i = 0; i < n; i += QUOTA) {
crypto.getRandomValues(a.subarray(i, i + Math.min(n - i, QUOTA)));
}
return a;
@GitHub30
GitHub30 / PowerShellUICulture.ps1
Last active October 1, 2022 12:20 — forked from sunnyone/PowerShellUICulture.ps1
Changing PowerShell UICulture
PS C:\Users\Admin> [Threading.Thread]::CurrentThread.CurrentUICulture
LCID Name DisplayName
---- ---- -----------
1041 ja-JP 日本語 (日本)
# example: Set-PowerShellUICulture -Name "en-US"
function Set-PowerShellUICulture {
param([Parameter(Mandatory=$true)]
@GitHub30
GitHub30 / Toast-RTEvent-Example.ps1
Last active August 17, 2022 03:28 — forked from Windos/Toast-RTEvent-Example.ps1
Example of trying to register a Windows RT event via PowerShell, specifically here we're looking at events on Toast Notifications
$XmlString = @"
<toast>
<visual>
<binding template="ToastGeneric">
<text>Default Notification</text>
<image src="C:\Windows\IdentityCRL\WLive48x48.png" placement="appLogoOverride" />
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" />
</toast>
@GitHub30
GitHub30 / n2.py
Last active August 7, 2022 08:32 — forked from MarcAlx/notification.py
Send Windows notifications from python3
import winsdk.windows.ui.notifications as notifications
import winsdk.windows.data.xml.dom as dom
from winsdk.windows.ui.notifications import ToastActivatedEventArgs, ToastDismissedEventArgs, ToastFailedEventArgs
# create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier()
# define your notification as string
tString = """
function toBaseN(num, base) {
if (num === 0) {
return '0';
}
var digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var len = Math.min(digits.length, base);
var result = '';
while (num > 0) {
result = digits[num % len] + result;
num = parseInt(num / len, 10);
@GitHub30
GitHub30 / hclustering.py
Created February 6, 2022 15:15 — forked from codehacken/hclustering.py
Agglomerative clustering using Scikit-Learn (with a custom distance metric)
"""
Hierarchial Clustering.
The goal of gist is to show to use scikit-learn to perform agglomerative clustering when:
1. There is a need for a custom distance metric (like levenshtein distance)
2. Use the distance in sklearn's API.
Adapted from: sklearn's FAQ.
http://scikit-learn.org/stable/faq.html
"""
@GitHub30
GitHub30 / decryptchromecookies.py
Last active April 4, 2024 09:08
Simple Decrypt Chrome/Firefox Cookies File (Python 3) - Windows
import sqlite3
def get_chrome_cookies(db=None):
import json
from base64 import b64decode
from win32.win32crypt import CryptUnprotectData # pip install pywin32
# should use Cryptodome in windows instead of Crypto
# otherwise will raise an import error
from Cryptodome.Cipher.AES import new, MODE_GCM # pip install pycryptodomex
@GitHub30
GitHub30 / turbo_colormap.py
Created August 20, 2019 17:02 — forked from mikhailov-work/turbo_colormap.py
Turbo Colormap Look-up Table
# Copyright 2019 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# Author: Anton Mikhailov
turbo_colormap_data = [[0.18995,0.07176,0.23217],[0.19483,0.08339,0.26149],[0.19956,0.09498,0.29024],[0.20415,0.10652,0.31844],[0.20860,0.11802,0.34607],[0.21291,0.12947,0.37314],[0.21708,0.14087,0.39964],[0.22111,0.15223,0.42558],[0.22500,0.16354,0.45096],[0.22875,0.17481,0.47578],[0.23236,0.18603,0.50004],[0.23582,0.19720,0.52373],[0.23915,0.20833,0.54686],[0.24234,0.21941,0.56942],[0.24539,0.23044,0.59142],[0.24830,0.24143,0.61286],[0.25107,0.25237,0.63374],[0.25369,0.26327,0.65406],[0.25618,0.27412,0.67381],[0.25853,0.28492,0.69300],[0.26074,0.29568,0.71162],[0.26280,0.30639,0.72968],[0.26473,0.31706,0.74718],[0.26652,0.32768,0.76412],[0.26816,0.33825,0.78050],[0.26967,0.34878,0.79631],[0.27103,0.35926,0.81156],[0.27226,0.36970,0.82624],[0.27334,0.38008,0.84037],[0.27429,0.39043,0.85393],[0.27509,0.40072,0.86692],[0.27576,0.41097,0.87936],[0.27628,0.42118,0.89123],[0.27667,0.43134,0.90254],[0.27691,0.44145,0.913
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import random
import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
from chainer import reporter
#!/usr/bin/env python
# coding: utf-8
import tweepy
import tw_key
CONSUMER_KEY = tw_key.twdict['cons_key']
CONSUMER_SECRET = tw_key.twdict['cons_sec']
ACCESS_TOKEN_KEY = tw_key.twdict['accto_key']
ACCESS_TOKEN_SECRET = tw_key.twdict['accto_sec']