Skip to content

Instantly share code, notes, and snippets.

import weechat
lorem_ipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam dapibus dolor ultricies malesuada semper. Nulla ac augue orci. Proin iaculis mi ipsum, a dapibus est porta vel. Donec gravida et elit sed iaculis. Praesent id mollis neque. Sed hendrerit rutrum odio, eu eleifend dui interdum ac. Donec nec sollicitudin enim. Aliquam in magna sit amet lectus tincidunt finibus ac a massa. Donec sed nunc tortor. Maecenas egestas facilisis urna, volutpat ultrices orci sagittis nec. Suspendisse aliquam at diam vel malesuada. Morbi a eros sed risus condimentum maximus. Mauris maximus velit in nibh dignissim tempor. Quisque lobortis finibus nunc, nec malesuada quam vehicula in. Integer quis eros nulla.'
def change_line_command_cb(data, current_buffer, args):
own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), buffer, 'own_lines')
line_pointer = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'last_line')
data = weechat.hdata_pointer(weechat.hdata_get('lin
@trygveaa
trygveaa / package.json
Created March 18, 2019 12:12
yarn upgrade issue
{
"dependencies": {
"nuxt-ts": "^2.4.5",
"typescript": "3.3.1",
"webpack": "^4.29.3"
}
}
#!/usr/bin/python2
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from websocket import create_connection
import json
import urllib2
try:
#!/usr/bin/python2
from websocket import create_connection
import json
import sys
import urllib2
rtm = json.loads(urllib2.urlopen('https://api.slack.com/api/rtm.connect?token=' + sys.argv[1]).read())
ws = create_connection(rtm['url'])
print(ws.recv())
@trygveaa
trygveaa / git-delete-merged
Last active June 6, 2017 07:51
Deletes all git branches that has been merged to master or the specified branch
#!/bin/bash
base_branch=${1:-master}
keep_branches="HEAD\|master\|bugfix\|$base_branch"
remote=$(git remote)
confirm () {
message=${1:-Are you sure?}
read -r -p "$message [y/N]" response
response=${response,,} # tolower
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use IO::Socket::INET6;
my $current_song;
if (my $server = IO::Socket::INET6->new(PeerAddr => ($ARGV[0] or 'localhost'), PeerPort => ($ARGV[1] or '6600'), Proto => 'tcp', Timeout => 5)) {
@trygveaa
trygveaa / mpd-pause-on-song-change.pl
Created March 20, 2017 12:32
MPD pause on song change
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use IO::Socket::INET6;
my $current_song;
if (my $server = IO::Socket::INET6->new(PeerAddr => ($ARGV[0] or 'localhost'), PeerPort => ($ARGV[1] or '6600'), Proto => 'tcp', Timeout => 5)) {
@trygveaa
trygveaa / wlan
Created May 11, 2016 17:02
Wrapper around wpa_cli for less typing
#!/bin/bash
wpa_cli='wpa_cli -i wlp2s0'
if [ -z "$1" ]; then
$wpa_cli status
elif [ "$1" == "c" ]; then
$wpa_cli
elif [ "$1" == "l" ]; then
$wpa_cli list_networks
@trygveaa
trygveaa / set_random_background.pl
Created March 12, 2016 23:36
Script to set a random background from desktopography or reddit
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use File::Temp qw(tempfile);
use LWP::Simple qw($ua get getstore is_success);
if (rand > 0.5) {
@trygveaa
trygveaa / getopts_example.sh
Created March 4, 2016 12:42
Shell getopts
#!/bin/sh
test=false
host=localhost
port=6600
while getopts ":th:p:" opt; do
case $opt in
t)
test=true