Skip to content

Instantly share code, notes, and snippets.

Avatar

k5.trismegistus k5trismegistus

View GitHub Profile
View blogger.py
import urllib.request
import bs4
import time
def fetch_page(url):
html = urllib.request.urlopen(url).read().decode('utf-8')
soup = bs4.BeautifulSoup(html)
return soup
View .Xmodmap
remove control = Super_L
keycode 37 = Mode_switch
keycode 31 = i I Up Up
keycode 44 = j J Left Left
keycode 45 = k K Down Down
keycode 46 = l L Right Right⏎
View convert.sh
#! /bin/bash
for file in toconvert/*
do
filename=`pwd`/$file
basename=`echo $filename | sed 's/.*toconvert\/\(.*\)\.[^\.]*$/\1/'`
targetname=`pwd`/converted/$basename'.mp4'
ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i $filename -loglevel error -c:v h264_vaapi $targetname -y
done
echo 'done'
View install.sh
#! /bin/bash
mkdir ~/tmp
cd ~/tmp
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -xvf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
make && sudo make install
cd ~/tmp
View hashtest.cpp
#include <stdio.h>
#include <string>
#include <eosiolib/eosio.hpp>
#include <eosiolib/crypto.h>
using namespace eosio;
class Hashtest : public contract {
public:
View OracleTest.sol
pragma solidity ^0.4.23;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract OracleTest is usingOraclize {
bool public isTrue;
event NewOraclizeQuery(string _description);
event NewOracleResultCount(bool _isTrue);
View nestedPromise.js
const wait = true;
const success = false;
const promise2 = new Promise((res, rej) => {
if (success) {
setTimeout(res, 1000, 2)
} else {
rej(3)
}
});
View calc.py
import sys
from lark import Lark, Transformer
class Calculator(Transformer):
def addition(self, items):
return items[0] + items[1]
def substraction(self, items):
return items[0] - items[1]
View mentekun.rb
require 'json'
module Middlewares
class Mentekun
CONFIG = {
users: {
read: [
{ methods: [:get], path: '/api/users' },
{ methods: [:get], path: %r{/api/users/\d+} },
View Problems_first.kt
/*
* Your task is to implement the sum() function so that it computes the sum of
* all elements in the given array a.
*/
fun sum(a: IntArray): Int {
when {
a.size > 0 -> return a.reduce{s1, s2 -> s1 + s2}
else -> println("Array must be longer than 2")
}