Skip to content

Instantly share code, notes, and snippets.

@umpirsky
umpirsky / keyboard-backlight
Last active January 7, 2018 23:08
Turn keyboard backlight on/off using https://github.com/MatMoul/g810-led
#!/bin/bash
# Turn keyboard backlight on/off using https://github.com/MatMoul/g810-led
g413-led -a FFFFFF # always turn on on startup (it turns off for some reason on reboot)
dbus-monitor --session "type=signal,interface=org.gnome.SessionManager.Presence,member=StatusChanged" |
while read x; do
case "$x" in
*"uint32 3"*) g413-led -a 000000;;
*"uint32 0"*) g413-led -a FFFFFF;;
@umpirsky
umpirsky / convert
Last active January 25, 2018 11:54
Nautilus script for converting subtitle encoding from Windows-1250 to utf-8
#!/bin/sh
# chardetect orignial
IFS_BAK=$IFS
IFS="
"
for line in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
iconv -f Windows-1250 -t utf-8//IGNORE $line > $line.tmp
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active March 26, 2024 18:32
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@akovalyov
akovalyov / File.orm.yml
Created May 18, 2015 08:12
Pure file upload with Doctrine entity listener, doctrine events and symfony2 dependency injection
App\Model\File:
type: entity
table: files
entityListeners:
App\Doctrine\EventListener\FileUploadListener:
prePersist: [upload]
preUpdate: [upload]
preRemove: [remove]
id:
id:
@srsbiz
srsbiz / gist:8373451ed3450c0548c3
Last active December 24, 2022 15:01
php AES-128-CBC mcrypt & openssl
<?php
function encrypt_mcrypt($msg, $key, $iv = null) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
if (!$iv) {
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
}
$pad = $iv_size - (strlen($msg) % $iv_size);
$msg .= str_repeat(chr($pad), $pad);
$encryptedMessage = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $msg, MCRYPT_MODE_CBC, $iv);
return base64_encode($iv . $encryptedMessage);
@brenopolanski
brenopolanski / install-indicator-synapse.md
Last active June 14, 2019 04:02
How to Install Indicator Synapse (Spotlight Alternative) on Ubuntu 14.04 LTS or Linux Mint 17

Indicator Synapse is a Spotlight Alternative, developed by Tom Beckmann.

spotlight-alternative

How to Install Indicator Synapse (Spotlight Alternative) on Ubuntu 14.04 LTS or Linux Mint 17 run this commands in terminal:

$ [sudo] add-apt-repository ppa:noobslab/apps
$ [sudo] apt-get update
$ [sudo] apt-get install indicator-synapse
@cursedcoder
cursedcoder / config.yml
Last active March 20, 2019 22:00
HWIOAuth with FOSUserBundle intergration + phpspec coverage
fos_user:
db_driver: orm
firewall_name: main
user_class: App\Entity\User
service:
user_manager: app.user_manager
hwi_oauth:
firewall_name: main
fosub:
anonymous
anonymous / main.js
Created November 25, 2013 10:17
reload sf2 wdt on ajax request
$(document).ajaxComplete(function(event, XMLHttpRequest){
var token = XMLHttpRequest.getResponseHeader('x-debug-token'),
protocol = window.location.protocol,
hostname = window.location.hostname;
if(token) {
$.get(protocol+'//'+hostname+'/_wdt/'+token, function(data){
@umpirsky
umpirsky / A.markdown
Last active August 3, 2023 18:14 — forked from olivierlacan/An_example.markdown
Sublime Text Monokai Sidebar Theme.
@merk
merk / AbstractInvoiceLineType.php
Created July 6, 2012 06:07
Symfony2 Form Polycollection for use with objects in an inheritance structure
<?php
// ...
class AbstractInvoiceLineType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...