Skip to content

Instantly share code, notes, and snippets.

View Darker's full-sized avatar

Jakub Mareda Darker

  • Czech Republic
View GitHub Profile
#define E .0000001f
bool fEqual(float x, float y)
{
return (x+E > y && x-E < y);
}
float4 rgba2hsla(float4 rgba) {
float M = max(rgba.x, rgba.y);
M = max(M, rgba.z);
function changeText(originalText) {
return "💩";
}
// Najde všechny texty v dokumentu
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, null);
// Sem budeme dávat nalezený texty
var node = null;
// dokud walker.nextNode() vrací text a ne null
while(node = walker.nextNode()) {
// "text node" má "data", to je text co je pak vidět v browseru
@Darker
Darker / stdout
Created April 19, 2018 18:46
Error when compiling visual sfm
jakub@pidizvik:~/vsfm$ make
mkdir -p build
mkdir -p bin
cd build; ar -x ../lib/VisualSFM.a; cd ..;
g++ -w -o bin/VisualSFM build/*.* -pthread -lGL -lGLU -lX11 -ldl -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfontconfig -lfreetype -lgthread-2.0 -pthread -lglib-2.0 lib/lapack.a lib/blas.a lib/libf2c.a lib/libjpeg.a
/usr/bin/ld: lib/lapack.a(dgeev.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib/lapack.a(dgehrd.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib/lapack.a(dgerqf.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib/lapack.a(dgesv.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: li
# generated by Slic3r 1.3.0-dev on Fri Feb 23 16:52:42 2018
[filament:ColorFabb Brass Bronze 1.75mm]
bed_temperature = 50
bridge_fan_speed = 100
compatible_printers =
cooling = 1
disable_fan_first_layers = 1
end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n"
extrusion_multiplier = 1
@Darker
Darker / My answer.md
Created February 9, 2018 10:32
Answer

There's multiple issues:

  • somethingIsTrue ? doSomething(); is not valid in JavaScript. See MDN on ternary operator
  • Frankly, I don't think Array.prototype.reduce is the right choice. Reduce creates something from all array members. I mean you could use it for this, but the code would be unnecesarily obscure. For generic looping, use either map (1:1 conversion of array elements) or forEach

I'd use forEach, or just classic for:

@Darker
Darker / gist:f081d5c9de04cdc31a93406f6b1e5c1a
Created September 4, 2017 20:59
Sablona pro analyzu otevrenych uctu ve fio bance.
var halire = 0;
var prispevky = 0;
document.querySelectorAll("td.amount.amount_value").forEach(function(elm) {
const cash = elm.getAttribute("data-value")*1;
if(cash>1) prispevky +=cash;
else halire+=cash;
});
[halire, prispevky]
@Darker
Darker / casy.js
Created September 3, 2017 18:11
Lesson times at ctu
var casy2 = [
["7:30", "8:15"],
["8:15", "9:00"],
["9:15", "10:00"],
["10:00", "10:45"],
["11:00", "11:45"],
["11:45", "12:30"],
["12:45", "13:30"],
["13:30", "14:15"],
["14:30", "15:15"],
console.log("This script changes cached resources' path in GreaseMonkey addon folder to force refresh.");
console.log("Press any key to start adding files.");
/*process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', ()=>{getFiles(updateLoop);}); */
var fs=require("fs");
var path = require("path");
/*var prompt = require('prompt-sync');
@Darker
Darker / spam_phishing.py
Created June 23, 2017 12:40
Sends random usernames and password to a phishing script to fuck with it
import httplib, urllib
params = {
"app": "",
"login_post": "1",
"url": "",
"anchor_string": "",
"username": "dsavffsfds",
"password": "fdsfdsfdsfds",
"horde_select_view": "auto",
"new_lang": "en_US"}
void Image::convolute(const int matrix[3][3], Image& target)
{
target.setSize(getWidth(), getHeight());
for(size_t y=0, yl=getHeight(); y<yl; ++y) {
for(size_t x=0, xl=getWidth(); x<xl; ++x) {
if(x==0 || y==0 || x+1==xl || y+1==yl) {
target.pixels[y][x] = pixels[y][x];
}
else {
target.pixels[y][x] = ((pixels[y-1][x-1]*matrix[0][0])