Skip to content

Instantly share code, notes, and snippets.

@killown
killown / dolphin-transfer.py
Created February 14, 2018 21:48
Uses transfer.sh to send files through dolphin file manager
#!/usr/bin/env python
import sys
import pyperclip
import subprocess
###################################################################################
# transfer.desktop file uses %f and gives full path and we only need the filename #
###################################################################################
##########################################################################
@killown
killown / string_list_size.py
Created May 7, 2017 20:39
string list size
#include <cstddef> // for std::size_t
#include <cstring>
#include <iostream>
template< class T, size_t N >
std::size_t length(const T (&)[N] )
{
return N;
};
int main(){
using namespace std;
@killown
killown / function_string_list.py
Created May 7, 2017 20:33
function string list
// string constructor
#include <iostream>
#include <string>
std::string teste(std::string nums[]){
int b = nums.length();
for(int a=0; a < b; a++)
std::cout << nums[a] << " ";
}
@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;
@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 / django-url-patterns.md
Last active November 19, 2017 13:59
List of Useful URL Patterns (Django)

Primary Key AutoField

Regex: (?P\d+)

url(r'^questions/(?P\d+)/$', views.question_details, name='question_details'),

Match

|URL |Captures |

@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 / 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 / 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()