Skip to content

Instantly share code, notes, and snippets.

@l4sh
l4sh / tempswap.sh
Created October 19, 2017 19:23
Create and enable a temporary swap file
#! /bin/bash
# Create and enable a temporary swap file
SWAPFILE="/tmp/swapfile1"
if [[ $1 == "on" ]]
then
echo Creating swap file on $SWAPFILE
dd if=/dev/zero of=$SWAPFILE bs=1024 count=524288
mkswap $SWAPFILE
@l4sh
l4sh / download-patches.sh
Created October 8, 2017 03:30
Download U-he Linux VSTs and free patches
#! /bin/bash
PATCHLIB_URL='http://www.u-he.com/PatchLib/'
function download_patches()
(
PLUGIN=$1
mkdir -p $PLUGIN
cd $PLUGIN
@l4sh
l4sh / ssh-wrapper
Created September 13, 2017 16:18
SSH wrapper to load ssh-agent and adding key
#! /bin/sh
# ~/bin/ssh-wrapper
# Start ssh-agent if not running, add key & run ssh
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.$HOSTNAME.sock
# Check if running and start agent
ssh-add -l 2>/dev/null >/dev/null
if [ $? -ge 2 ]
then
@l4sh
l4sh / check_redis.sh
Created August 25, 2017 14:39
Check if a Redis container running on docker is OK by sending a PING to redis instance running in container
#! /bin/bash
#
# Check if a Redis container running on docker is OK
# by sending a PING to redis instance running in container
if [[ $# -eq 0 ]] ; then
echo 'Send PING to redis instance running in docker container'
echo 'It should return PONG+'
echo 'Usage:'
echo ' check_redis.sh container_name'
@l4sh
l4sh / CleanUpEmail.cs
Created June 28, 2017 15:09
C# clean up email
public static string CleanUpEmail(string emailString)
{
emailString = emailString.ToLower();
string normalized = emailString.Normalize(NormalizationForm.FormD);
StringBuilder resultBuilder = new StringBuilder();
foreach (var character in normalized)
{
UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(character);
@l4sh
l4sh / req.js
Created March 28, 2017 13:06
Promisify & simplify XHR
/**
* Promisify & simplify XHR
*/
var req = {
/**
* Create a new request
*/
new: function(method, url, data) {
data = data || null;
@l4sh
l4sh / git-rm.sh
Created February 19, 2017 05:24
agregar y eliminar archivo de repo manteniendolo en el sistema de archivos
l4sh at aria in ~/tmp/mi-repo (master)
$ git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
l4sh at aria in ~/tmp/mi-repo (master)
$ touch archivo
@l4sh
l4sh / update-comments-invoice.xml
Created February 18, 2017 03:25
Retail Pro 9 Invoice.xml minimal structure
<?xml version="1.0" encoding="utf-8"?>
<DOCUMENT>
<INVOICES>
<INVOICE invc_sid="123456789012345678" sbs_no="2" invc_type="0">
<INVC_COMMENTS>
<INVC_COMMENT comment_no="1" comments="Test comment" />
</INVC_COMMENTS>
</INVOICE>
</INVOICES>
</DOCUMENT>
@l4sh
l4sh / readme.md
Last active January 30, 2017 01:14
Add Bootstrap to create-react-app

Install bootstrap

npm install bootstrap react-bootstrap -S

Import CSS & theme

Edit index.js and add the following imports

@l4sh
l4sh / aes128_example.php
Last active April 29, 2016 00:52
AES 128 CBC encription example (PHP)
<?php
/**
* AES 128 CBC encription example
*/
// Must be 64 chars long & valid hexadecimal. Store it some place safe.
$hex_key = "2cc4e0d365011b7d86b235c4e3dddee45ac3a76dca8536fe10d58d1d481d4b8b";
$key = pack('H*', $hex_key);