Skip to content

Instantly share code, notes, and snippets.

@suplo
suplo / vcode.md
Last active January 11, 2024 16:36
Quick hack to open vscode from fish shell

The code extension does not allow me to open folder with vscode from command line.
Solution: Add the following function to ~/.config/fish/config.fish

function vcode
  open -a "Visual Studio Code.app" $argv
end

then using vcode $folder to open $folder

@suplo
suplo / terminal.md
Created January 5, 2017 06:04
Getting around "su: must be run from a terminal"

Solution to su: must be run from a terminal when working in reverse shell (PHP).

echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py

Reference

@suplo
suplo / settings.json
Created June 16, 2023 06:11
My VS Code User settings
{
"workbench.colorTheme": "Gruvbox Light (Hard)",
"files.trimTrailingWhitespace": true,
"editor.renderWhitespace": "all",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Source ```https://www.hass.de/files/nodes/story/58/setupiis8forsslperfectforwardsecrecy_v14.ps1```
# Copyright 2014, Alexander Hass
# http://www.hass.de/content/setup-your-iis-ssl-perfect-forward-secrecy-and-tls-12
#
# Version 1.4
# - RC4 has been disabled.
# Version 1.3
# - MD5 has been disabled.
@suplo
suplo / VisionApiFocusFix.java
Last active January 29, 2019 04:27 — forked from gregkorossy/VisionApiFocusFix.java
Mobile Vision API fix for missing autofocus feature
/*
* IF YOU WANT TO JUST ACCESS THE CAMERA INSTANCE SO THAT YOU CAN SET ANY OF THE PARAMETERS, VISIT THE FOLLOWING LINK:
* https://gist.github.com/Gericop/364dd12b105fdc28a0b6
*/
/**
* <p>
* Sets the Mobile Vision API provided {@link com.google.android.gms.vision.CameraSource}'s
* focus mode. Use {@link Camera.Parameters#FOCUS_MODE_CONTINUOUS_PICTURE} or
* {@link Camera.Parameters#FOCUS_MODE_CONTINUOUS_VIDEO} for continuous autofocus.
@suplo
suplo / elb.py
Created July 19, 2018 08:24 — forked from philfreo/elb.py
Python script to remove/add an EC2 instance into an AWS ELB. Helpful during deployments. (Using Flask / Flask-Script but easily modifiable)
#!/usr/bin/env python
import time
import boto
import boto.ec2.elb
import boto.utils
from flask.ext.script import Manager
from closeio.main import setup_app
@suplo
suplo / gist:1c3656649acc9232d94c99714f38ac62
Created July 10, 2018 10:07 — forked from dvliman/gist:10402435
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
@suplo
suplo / what-forces-layout.md
Created July 9, 2018 21:12 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@suplo
suplo / htmlentity.js
Created April 11, 2018 16:31 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@suplo
suplo / performance.txt
Created December 28, 2017 05:38 — forked from dstroot/performance.txt
Performance Tuning your TCP Stack
#!/bin/bash
echo "*****************************************"
echo " Based on information from Google"
echo " http://dev.chromium.org/spdy/spdy-best-practices"
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Changing initcwnd and initrwnd"
echo " Step 1: check route settings."