Skip to content

Instantly share code, notes, and snippets.

View kphrx's full-sized avatar

kPherox kphrx

View GitHub Profile
const OTPAuth = require('otpauth');
require('dotenv').config();
module.exports = function(issuer) {
let secrets = process.env.TOTP_SECRETS.split(' ')
, secretsDict = secrets.reduce((previous, current) => {
let secret = current.split(':');
previous[secret[0]] = secret[1];
return previous;
}, {})
@kphrx
kphrx / IsAssocForCollectionServiceProvider.php
Last active June 18, 2018 17:21
Add `isAssoc` to Collection class
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
use Illuminate\Support\Arr;
class IsAssocForCollectionServiceProvider extends ServiceProvider
{
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
class RejectWithKeyCollectionServiceProvider extends ServiceProvider
{
public function boot()
{
#!/bin/bash
# Need scope: public_repo
GITHUB_TOKEN=<token>
GITHUB_USER=<username>
# Get latest version from git repository
#cd $(dirname $0)
#
@kphrx
kphrx / jump-to-game-of-kancolle.user.js
Last active March 23, 2022 17:27
Install from raw
// ==UserScript==
// @name Set scroll position to game of KanColle
// @namespace https://gist.github.com/kPherox
// @version 1.1.1
// @description Jump to game frame top of KanColle.
// @author kPherox <[email protected]>
// @match http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854*
// @run-at document-end
// @grant GM_addStyle
// @updateURL https://gist.github.com/kphrx/fb4f21c1bbfa6bcbb484c74824866e65/raw/jump-to-game-of-kancolle.user.js
@kphrx
kphrx / delete_of_map_image_2nd.sql
Last active August 20, 2019 11:13
MyFleetGirls Delete Old Version Resources
DELETE FROM map_image_2nd
WHERE EXISTS (
SELECT 1
FROM map_image_2nd AS m
WHERE map_image_2nd.area_id = m.area_id
AND map_image_2nd.info_no = m.info_no
AND map_image_2nd.suffix = m.suffix
AND map_image_2nd.version < m.version
);

Keybase proof

I hereby claim:

  • I am kphrx on github.
  • I am kpherox (https://keybase.io/kpherox) on keybase.
  • I have a public key whose fingerprint is 55A2 8362 FE57 05D3 FF27 0136 C047 51C2 BFA2 F62D

To claim this, I am signing this object:

update-pleroma

systemd timer unitで定期的に実行させる形 /opt/pleromaにpleromaをcloneしておく。その時upstreamを設定する

  1. dotenv.exmapledotenvにコピーして適宜変更
  2. update-pleroma.service/path/todotenvupdate-pleroma.shの置いてあるパスに向ける
  3. update-pleroma.serviceupdate-pleroma.timerをsystemdの管理下へ置いてsystemctl start update-pleroma.timerを実行
@kphrx
kphrx / backquote-glyph-class-change.pe
Created October 8, 2019 09:41
backquote-glyph-class-change.pe /path/to/font.ttf
#!/usr/local/bin/fontforge
i=1
while ( i<$argc )
Open($argv[i])
Print($argv[i])
Select("`")
beforeClass = GlyphInfo("Class")
SetGlyphClass("base")
@kphrx
kphrx / rolling-update.sh
Last active June 29, 2021 14:09
docker container rolling update script with docker-compose. service name: "web"
#!/bin/sh
OLD_CONTAINER=$(docker ps --all --format "{{.Names}}" --filter name=web)
docker-compose pull web
docker-compose up -d --no-deps --scale web=2 --no-recreate web
NEW_CONTAINER=$(docker ps --all --format "{{.Names}}" --filter name=web | grep -v "$OLD_CONTAINER")
echo -n "Starting $NEW_CONTAINER ... "