Skip to content

Instantly share code, notes, and snippets.

View somidad's full-sized avatar

Seokseong Jeon somidad

View GitHub Profile
@somidad
somidad / logseq-publish-github-pages-wa.js
Last active June 25, 2022 07:54
Script to remove U+2029 from published Logseq graph for GitHub Pages
const { readFileSync, writeFileSync } = require("fs");
function indexOfUnicode(s, u) {
let i = -1;
for (i = 0; i < s.length; i++) {
if (s.charCodeAt(i) === u) {
break;
}
}
return i;
@somidad
somidad / workflow.yml
Last active January 15, 2025 08:43
GitHub Workflow to check any change on git repository and do something if any
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
- name: Check if there is any change
id: get_changes
# deprecated. see https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
#run: echo "::set-output name=changed::$(git status --porcelain | wc -l)"
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Do something if there is any change
if: steps.get_changes.outputs.changed != 0
run: do something
@somidad
somidad / decode_jwt.js
Created April 10, 2022 02:42
Decode JWT (without verification)
const [header, payload, signature] = jwt.split('.');
const buffer = Buffer.from(payload, 'base64');
const decoded = JSON.parse(buffer);
@somidad
somidad / gist:4089050d49230df1920a9001516fa241
Created January 2, 2018 12:38
Remove YouTube Red logo for 'Enhancer for YouTube'
var idLogoContainer = document.getElementById('logo-container')
var classLogoRed = idLogoContainer.getElementsByClassName('logo-red')
console.log(classLogoRed)
if (classLogoRed.length) {
var tag = classLogoRed[0]
console.log(tag)
tag.style.backgroundImage = 'none'
console.log(tag.style.background)
}
@somidad
somidad / google-scholar-to-rss.gs
Last active January 2, 2018 10:32
Google Scholar Alert (G)Mails to RSS feeds
var LABEL = '<your GMail label name storing Google Scholar Alert>'
var RECEIVER = '<your Blogger e-mail address>'
function get_quota() {
var quota = MailApp.getRemainingDailyQuota()
Logger.log(quota)
return quota
}
function myFunction() {
# http://stackoverflow.com/questions/8488758
function matlab_figure_without_focus(h)
set(0, 'CurrentFigure', h);
@somidad
somidad / git-root.sh
Last active April 10, 2017 16:28
A shortcut to git root
# This git alias allows you to move
# to the root of a local git repository
# (if you are in the repo)
# define a shortcut to git root
git config --global alias.root 'rev-parse --show-toplevel'
# Usage: go to the git root
cd $(git root)
# Usage: add all under the git root
@somidad
somidad / gist:36fc741143d65e247d571ab391cb98f9
Created February 10, 2017 08:41
/etc/dbus-1/system.d/NetworkManager.conf:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="org.freedesktop.NetworkManager"/>
<allow send_destination="org.freedesktop.NetworkManager"/>
<allow send_interface="org.freedesktop.NetworkManager"/>
<allow own="org.freedesktop.NetworkManager.PPP"/>
@somidad
somidad / sbin.dhclient
Created February 8, 2017 04:03
apparmor for /sbin/dhclient
# vim:syntax=apparmor
# Last Modified: Fri Jul 17 11:46:19 2009
# Author: Jamie Strandboge <jamie@canonical.com>
#include <tunables/global>
/sbin/dhclient {
#include <abstractions/base>
#include <abstractions/nameservice>
capability net_bind_service,
@somidad
somidad / decodeurl.py
Created January 20, 2017 13:21
Rename URL encoded file name
#!/usr/bin/env python3
import urllib.parse as parse
import os
def print_usage():
print('Usage: decodeurl.py encodedfilename')
def main(fname):
if not os.path.isabs(fname):