Skip to content

Instantly share code, notes, and snippets.

View spidgorny's full-sized avatar
💭
Building Flutter apps

Slawa Pidgorny spidgorny

💭
Building Flutter apps
View GitHub Profile
@spidgorny
spidgorny / AutoForwardSAP.js
Created November 29, 2016 09:38
SAP Learning Hub Hacks
(function () {
function setVideoEndHandler() {
let iframeDocument = window
.frames['contentContainer']
.contentDocument;
let video = iframeDocument.querySelector('video');
if (!video) {
video = iframeDocument.querySelector('audio');
}
@spidgorny
spidgorny / MyRandomFactory.php
Created February 23, 2017 21:53
RandomLib fix for PHP 7.1 which does not have mcrypt anymore
<?php
use RandomLib\Factory;
class MyRandomFactory extends Factory {
public function __construct() {
parent::__construct();
$this->mixers = [];
$this->registerMixer('OpenSSLMixer', OpenSSLMixer::class);
@spidgorny
spidgorny / manage.sh
Created January 4, 2018 20:36
move android DCIM photos to the folders corresponding to the month like 2018-01/
#!/bin/bash
year=2018
for i in `seq -f "%02g" 1 12`;
do
mask="???_$year$i*";
folder="$year-$i/";
mkdir -p $folder;
echo ""
echo -e "mv \t $mask \t $folder";
mv $mask $folder;
@spidgorny
spidgorny / ebay-f12-console.js
Created February 7, 2018 11:47
Find the average price of all ebay offers on the page. Press F12 and run this in the console.
$('.POSITIVE').map((i, el) => {
let k = $(el).text().replace('EUR ', '');
return parseInt(k);
}).get().reduce((a, b) => a + b, 0)
/$('.POSITIVE').length
function analyze(i, callback) {
setTimeout(() => {
callback('result 123');
}, Math.random()*10000);
// long thinking time....
// callback('result 123');
}
async function analyzeAsync(i) {
return new Promise((resolve, reject) => {
@spidgorny
spidgorny / you_id.sql
Created June 19, 2018 11:38
YouTube like unique ID in PostgreSQL without plugins
-- function returns random string key like: cg8rP, QUdfX, 4veH7
CREATE OR REPLACE FUNCTION you_id()
RETURNS varchar AS $$
DECLARE
num FLOAT;
key TEXT;
bin BYTEA;
BEGIN
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
import 'dart:convert';
import "dart:io";
import 'package:html/dom.dart';
import 'package:html/parser.dart' as parser;
import "package:http/http.dart" as http;
import 'package:http/http.dart';
import "package:yaml/yaml.dart";
main() async {
# List samba shares
smbclient -L 192.168.1.189 -U depidsvy
# mount NFS
sudo mount 192.168.1.189:/volume1/photo /media/nas/photo
# mount samba share to a folder
sudo mount -t cifs -o username=depidsvy,password=$pw,uid=slawa,gid=users //192.168.1.189/photo /media/nas/photo2
# mount SFTP
// you can run this tutorial - it's executable
// fake function for demonstration
async function fetchSomething(item) {
return item;
}
async function learnLoops() {
// let's have some simple array first
// note that each value has also an 0-base index