Skip to content

Instantly share code, notes, and snippets.

@killown
killown / thunar-resize-image.py
Created December 25, 2015 03:27
thunar resize image
from easygui import *
import sys
import os
from PIL import Image
size = enterbox(msg='Enter the image size, example: 800x600', title=' ', default='', strip=True)
filename = sys.argv[-1]
width = size.split('x')[0]
height = size.split('x')[1]
img = Image.open(os.path.join(directory, image))
@killown
killown / SendToGist.py
Last active April 2, 2017 17:00
Send to gist using gtk
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
import subprocess
import os
def run_gist(description, file_content, filename):
file_path = os.path.join("/tmp/", filename)
@killown
killown / sortdict.py
Last active April 2, 2017 17:01
Sort Dict
#!/usr/bin/env python3
import operator
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=operator.itemgetter(1))
@killown
killown / color-picker.py
Created April 3, 2017 04:00
Color Picker
#!/usr/bin/env python3
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
import xerox
picker = Gtk.ColorSelectionDialog("Color Picker")
@killown
killown / process-pid.py
Created April 4, 2017 14:08
Get Process Pid
def get_pid(name):
outputCMD = subprocess.Popen(
['pidof', 'vivaldi-bin'], stdout=subprocess.PIPE)
return outputCMD.stdout.readlines()
@killown
killown / sort-dict.py
Created April 4, 2017 16:23
sort dict
def sort_dict(d):
return dict(sorted(d.items(), key=operator.itemgetter(1)))
@killown
killown / image-creator-for-speedial-vivaldi.py
Created April 4, 2017 16:41
Vivaldi Speedial Image Creator
#!/usr/bin/env python3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@killown
killown / sizeofthings.cpp
Created May 4, 2017 15:27
sizeof list C++
#include <iostream>
int main(){
using namespace std;
short things[] = {1,2,3,4,5};
int num_elements = sizeof things / sizeof (short);
cout << num_elements;
}
@killown
killown / toupper.py
Last active May 5, 2017 13:17
upper all string in loop
#include <iostream>
int main()
{
using namespace std;
string s("Hello World!!!");
// convert s to uppercase
for (auto &reference_to_s : s) // for every char in s (note: reference_to_s is a reference)
reference_to_s = toupper(reference_to_s); // reference_to_s is a reference, so the assignment changes the char
cout << s << endl;
}
@killown
killown / string-function.cpp
Last active May 7, 2017 19:32
passing string to a function
#include <iostream>
std::string safada(std::string input) {
return input;
}
int main() {
using namespace std;
cout << "eae manel já cherou uma hoje?" << endl;
string oi;