Skip to content

Instantly share code, notes, and snippets.

@strarsis
strarsis / docker-env
Created January 16, 2018 15:46 — forked from mmarchini/docker-env
Docker Env converter from Windows to WSL
#!/usr/bin/env python3
from subprocess import run, PIPE
completed_process = run(["docker-machine.exe", "env", "--shell", "bash"], stdout=PIPE)
docker_env = completed_process.stdout.decode("ascii")
for line in docker_env.split("\n"):
if "DOCKER_CERT_PATH" in line:
@strarsis
strarsis / howto.md
Created February 24, 2018 14:28
SASS mixin for making <object> element clickable/selectable (SVG)
// For making <object> elements clickable (SVG)
@mixin object-clickable(
  $pseudo: before
) {
  position: relative;

  &:#{pseudo} {
    position: absolute;
    top: 0;
@strarsis
strarsis / functions.php
Created March 5, 2018 22:53 — forked from kloon/functions.php
WooCommerce Dropdown Product Quantity, fully compatible with Min/Max quantities extension
<?php
// Place the following code in your theme's functions.php file
// override the quantity input with a dropdown
function woocommerce_quantity_input() {
global $product;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
@strarsis
strarsis / indd_page_extract.jsx
Created March 11, 2018 01:15 — forked from bastien/indd_page_extract.jsx
Extracting a page from an InDesign document (2 different approaches)
var doc = app.activeDocument;
if(doc.saved == true)
{
extract(2);
}
else
{
alert("Save you file.");
}
@strarsis
strarsis / gist:c900cb342140ec7d1439b35c05b1cd26
Created March 11, 2018 01:33 — forked from kuyseng/gist:2792080
javascript: indesign progress bar
function index_progress_bar(title) {
var w = new Window("palette", title, undefined);
w.orientation = "column";
var text_group = w.add("group");
text_group.orientation = "column";
var file_name = text_group.add("statictext", [0,0,350,20], "calculating..");
var remain = text_group.add("statictext", [0,0,350,20], "Remain: ..");
text_group.alignChildren = "left";
var progressbar = w.add("progressbar", undefined, 0, 100);
progressbar.preferredSize = [350,20];
@strarsis
strarsis / wpdb-transactions
Created March 14, 2018 20:56 — forked from nciske/wpdb-transactions
MySQL database transaction, using the WordPress database object $wpdb. Requires the InnoDB table format.
<?php
global $wpdb;
// Start Transaction
$wpdb->query( "START TRANSACTION" );
// Do some expensive/related queries here
//$wpdb->query("DELETE FROM table WHERE form_id = '1' ");
//$wpdb->query("DELETE FROM data WHERE form_id = '1' ");
// set $error variable value in error handling after $wpdb modifications
@strarsis
strarsis / .bashrc
Created March 16, 2018 18:02
Vagrant on WSL (Bash on Windows)
# Vagrant
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH=$PATH:/mnt/c/Program\ Files/Oracle/VirtualBox
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/<Windows Username>"
@strarsis
strarsis / dom-insert-after.php
Created March 26, 2018 22:27 — forked from deathlyfrantic/dom-insert-after.php
why doesn't the DOM spec include an insertAfter method, srsly guys
<?php
/** Inserts a new node after a given reference node. Basically it is the complement to the DOM specification's
* insertBefore() function.
* @param \DOMNode $newNode The node to be inserted.
* @param \DOMNode $referenceNode The reference node after which the new node should be inserted.
* @return \DOMNode The node that was inserted.
*/
function insertAfter(\DOMNode $newNode, \DOMNode $referenceNode)
{
if($referenceNode->nextSibling === null) {
@strarsis
strarsis / test.min.svg
Last active April 1, 2018 02:27
svgo issue (svgo --multipass --pretty --enable=inlineStyles -i test.svg -o test.min.svg)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@strarsis
strarsis / dumprequest.php
Created April 16, 2018 15:28 — forked from magnetikonline/dumprequest.php
PHP script to dump full HTTP request to file (method, HTTP headers and body).
<?php
// https://gist.github.com/magnetikonline/650e30e485c0f91f2f40
class DumpHTTPRequestToFile {
public function execute($targetFile) {
$data = sprintf(
"%s %s %s\n\nHTTP headers:\n",
$_SERVER['REQUEST_METHOD'],