Skip to content

Instantly share code, notes, and snippets.

@vfsoraki
vfsoraki / vfex.el
Last active January 14, 2024 09:20
ELisp code to switch between controller, view and templates in an Elixir Phoenix project
(setq
vfex--view-regex-old "^lib/\\(.+\\)/views/\\(.+\\)_view.ex"
vfex--template-regex-old "^lib/\\(.+\\)/templates/\\(.+\\)/"
vfex--view-regex-new "^lib/\\(.+\\)/controllers/\\(.+\\)_html.ex"
vfex--template-regex-new "^lib/\\(.+\\)/controllers/\\(.+\\)_html/"
vfex--controller-regex "^lib/\\(.+\\)/controllers/\\(.+\\)_controller.ex"
vfex--liveview-regex "^lib/\\(.+\\)/live/\\(.+\\)_live.ex"
vfex--liveview-template-regex "^lib/\\(.+\\)/live/\\(.+\\)_live.html.heex")
(defun vfex--dot-p (name)
function FindProxyForURL(url, host) {
if (host.endsWith('.ir')) {
return 'DIRECT';
}
return 'SOCKS5 127.0.0.1:10002;SOCKS 127.0.0.1:10002';
}
@vfsoraki
vfsoraki / svgtodxf.sh
Created January 20, 2020 10:42
Convert SVG to DXF in Linux using Inkscape and pstoedit
#! /bin/bash
# Install required applications
# Ubuntu:
# apt-get install inkscape pstoedit
# Arch:
# pacman -S inkscape pstoedit
function svgToEps()
{
@vfsoraki
vfsoraki / deploy.sh
Created December 26, 2019 18:13
Simple deploy script for `mix release`
#!/bin/bash
set -e
SERVER=someserver
DEPLOY_PATH=/some/path
START_SCRIPT=${DEPLOY_PATH}/bin/deploy_name
RELEASE_NAME=master
RELEASE_TAR=deploy_name-${RELEASE_NAME}.tar.gz
export MIX_ENV=prod
@vfsoraki
vfsoraki / deploy.sh
Created November 7, 2019 08:54
Simple bash script to facilitate deploying projects to shared hosting using git
#!/usr/bin/env bash
## This is a simple bash script to help deploy git-based projects to shared hostings.
## It work by tracking last deployed commit in a file (see below for file name).
## When you run this script, all files changed since last deployed commit up to now
## are put into a .tar.gz file (see below for file name), so you can easily upload and
## unzip it on shared hosting.
LAST_COMMIT_FILE=.last.deploy
OUTPUT_FILE=file.tar.gz
@vfsoraki
vfsoraki / deploy.sh
Created October 26, 2019 21:51
A simple bash script to deploy a simple app to server using just SSH. Tested with Lumen/Laravel
#!/usr/bin/env bash
# This script is used to simply copy some files using `rsync`
# and then running some commands on server.
# Command can be run synchronously, or in background.
# For example, your can restart your `supervisor` workers
# and PHP-FPM after copying new files.
# NOTE: This script does not require any kind of version control, e.g. `git`
# Server name. Define the connection parameters in `~/.ssh/config` so that a
@vfsoraki
vfsoraki / console.php
Created October 18, 2019 22:57
Run arbitrary scripts in context of a Laravel application
<?php
/**
* This Artisan command can run any file in the context of application.
* It can be useful to test some scripts in production/staging to see what's happening.
* You can also use `$this->*` functions in script.
* This reads scripts from `storage` folder, but nothing prevents you from changing it.
**/
Artisan::command('run:script {script}', function ($script) {
$full_path = storage_path($script);
if (file_exists($full_path)) {