Skip to content

Instantly share code, notes, and snippets.

@linoskoczek
linoskoczek / codeql-security-queries-aio.sh
Last active August 2, 2022 13:28
A script to set up a local CodeQL environment (or update if already present) and scan it using Security queries. Results are saved in CSV files and merged into a single CSV afterwards. Empty results are removed. Before running, edit SOURCE_ROOT, PLANG and PLATFORM variables. Tested only on Linux.
#!/bin/bash
# VARIABLES TO EDIT
SOURCE_ROOT="/home/path/to/the/code/that/you/want/to/scan" # might be a good idea to remove all special characters from the name
PLANG="csharp" # cpp, csharp, go, java, javascript, python, ruby
PLATFORM="linux64" # linux64, osx64, win64
# VARIABLES NOT TO EDIT
DATABASE_NAME="${SOURCE_ROOT##*/}_db"
# cd TO SCRIPT DIR
@linoskoczek
linoskoczek / http-requests-kotlin.kt
Last active September 17, 2021 09:48
Very easy and clear Kotlin functions that send GET/POST requests and return the response on Android.
// Add this line in your build.gradle dependencies {}:
// implementation("com.android.volley:volley:1.2.1")
fun sendGet(): String {
val url = URL("https://website.com")
with(url.openConnection() as HttpURLConnection) {
requestMethod = "POST"
println("\nSent 'GET' request to URL : $url; Response Code : $responseCode")
@linoskoczek
linoskoczek / plugins.sh
Created September 7, 2020 13:26
Download source code of plugins on a list from WordPress Plugins SVN
#!/bin/bash
# in plugins.txt there is a list of plugin names (like contact-form-7), each in separate line
while read p; do
mkdir $p
cd $p
svn checkout https://plugins.svn.wordpress.org/$p/trunk
cd ..
done < plugins.txt
@linoskoczek
linoskoczek / generator.js
Created February 5, 2020 12:25
Generator numerów PESEL w JS minified
function x(){function t(t,r){return t+Math.floor((r-t)*Math.random())}function r(t){return("00"+Math.floor(t%100).toString(10)).slice(-2)}var n,e,o,u,a,c,i;return n=t(1800,2300),e=function(t){switch(t){case 18:return 80;case 19:return 0;case 20:return 20;case 21:return 40;case 22:return 60}}(Math.floor(n/100)),o=t(1,13),u=t(1,new Date(n,o+1,0).getDate()+1),a=o+e,c=("0000"+t(0,1e4).toString(10)).slice(-4),(i=r(n)+r(a)+r(u)+c)+function(t){var r,n=t.split("").map(function(t){return+t}),e=[1,3,7,9,1,3,7,9,1,3],o=0;for(r=0;r<e.length;r+=1)o+=e[r]*n[r];return o=(10-o%10)%10}(i)}
Wywołanie:
`x()`
==
Oryginał: https://github.com/marcin-chwedczuk/nip_regon_pesel/blob/master/index.html
@linoskoczek
linoskoczek / slackDarkThemeLinesToAdd.js
Last active October 28, 2018 21:43
Add it to the very end of files: _/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js_ and _/usr/lib/slack/resources/app.asar.unpacked/src/static/index.js_ (Copyright of script: https://github.com/d-fay/slack-black-theme; copyright of theme: https://userstyles.org/styles/154599/slack-tomorrow-dark-slate)
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://gist.github.com/linoskoczek/6e9c3c2a9e5a511785b319335f7762e5/raw/d4fae48afcff526dabba67181e6fc6b6c660f8d2/slackDarkTheme.css';
let cssPromise = fetch(cssPath).then(response => response.text());
@linoskoczek
linoskoczek / slackDarkTheme.css
Last active October 28, 2018 21:40
Slack Tomorrow Dark Slate Theme taken from here: https://userstyles.org/styles/154599/slack-tomorrow-dark-slate
/* copyright: https://userstyles.org/styles/154599/slack-tomorrow-dark-slate */
/* Scrollbar Chrome*/
*::-webkit-scrollbar
{
width: 10px !important;
height: 10px !important;
background: #1e1e1e !important;
border: 1px solid #252525 !important;
}
@linoskoczek
linoskoczek / rotate-screen.sh
Last active March 4, 2018 11:34
Commands that can be used to rotate given screen in Linux without using any settings. Can be easily attached to keyboard shortcuts.
# install xrandr
sudo pacman -S xorg-xrandr
# check connected displays
xrandr
# rotate screen connected to VGA
xrandr --output DP1 --rotate left
xrandr --output DP1 --rotate right
xrandr --output DP1 --rotate normal
@linoskoczek
linoskoczek / cloneWordpressComments.sql
Last active February 28, 2018 23:11
This SQL will update not approved comments so that they have same content (chosen randomly) as those which are approved. Additionally, those unapproved comments will have random post ID assigned. Terribly slow unfortunately.
DROP PROCEDURE IF EXISTS update_comments;
DELIMITER $$
CREATE PROCEDURE update_comments()
BEGIN
DECLARE commentId bigint;
DECLARE v_finished INTEGER DEFAULT 0;
DECLARE messageCur CURSOR FOR SELECT comment_ID FROM wp_comments WHERE comment_approved = 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_finished = 1;
@linoskoczek
linoskoczek / Restaurant: Microsoft SQL Server (Transact SQL).sql
Created January 27, 2018 13:01
(School project) Transact SQL (Microsoft SQL Server) - restaurant database. Tables, triggers, procedures, cursors...
/* CLEANING UP PREVIOUS THINGS */
ALTER TABLE TBL DROP CONSTRAINT FK_WAITER;
ALTER TABLE BOOKING DROP CONSTRAINT FK_TABLE;
ALTER TABLE BOOKING DROP CONSTRAINT FK_CUSTOMER;
ALTER TABLE ORDR DROP CONSTRAINT FK_DISH;
ALTER TABLE WAITER DROP CONSTRAINT PK_WAITER;
ALTER TABLE TBL DROP CONSTRAINT PK_TABLE;
ALTER TABLE CUSTOMER DROP CONSTRAINT PK_CUSTOMER;
ALTER TABLE BOOKING DROP CONSTRAINT PK_BOOKING;
ALTER TABLE MENU DROP CONSTRAINT PK_MENU;
@linoskoczek
linoskoczek / Restaurant: Oracle (PL-SQL).sql
Last active January 27, 2018 13:00
(School project) PL/SQL (Oracle) - restaurant database. Tables, triggers, procedures, cursors...
/* CLEANING UP PREVIOUS ONES */
ALTER TABLE TBL DROP CONSTRAINT FK_WAITER;
ALTER TABLE BOOKING DROP CONSTRAINT FK_TABLE;
ALTER TABLE BOOKING DROP CONSTRAINT FK_CUSTOMER;
ALTER TABLE ORDR DROP CONSTRAINT FK_DISH;
ALTER TABLE WAITER DROP CONSTRAINT PK_WAITER;
ALTER TABLE TBL DROP CONSTRAINT PK_TABLE;
ALTER TABLE CUSTOMER DROP CONSTRAINT PK_CUSTOMER;
ALTER TABLE BOOKING DROP CONSTRAINT PK_BOOKING;
ALTER TABLE MENU DROP CONSTRAINT PK_MENU;