Skip to content

Instantly share code, notes, and snippets.

@arudmin
arudmin / images_as_url.ocmod.xml
Last active May 7, 2018 06:40
images_as_url.ocmod.xml
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Images as URL for OpenCart 2.x</name>
<code>00000002</code>
<version>0.78</version>
<author>Arudmin</author>
<link>https://gist.github.com/arudmin/</link>
<file path="catalog/model/tool/image.php">
<operation>
<search><![CDATA[if (!is_file(DIR_IMAGE . $filename)) {]]></search>
@arudmin
arudmin / image.php
Last active November 25, 2018 01:05
allows to import images as URL to opencart
// catalog/model/tool/image.php
if (!is_file(DIR_IMAGE . $filename)) {
if (filter_var($filename, FILTER_VALIDATE_URL)) {
// generating dirname as first digit of productID (from filename) // PHP_EOL
preg_match_all('/_(\d{4,6})/m', basename($filename), $matches, PREG_SET_ORDER, 0);
$image_dir = $matches[0][1] ? $matches[0][1][0] : 'temp';
$image_name = $matches[0][1] ? basename($filename) : substr(base64_encode($filename), 0, 7);
$image_path = 'catalog/' . $image_dir . '/' . $image_name;
@arudmin
arudmin / fade-gradient.js
Last active August 29, 2015 14:14
js-fade-gradient
function updateGradient() {
var a = colors[colorIndices[0]],
b = colors[colorIndices[1]],
c = colors[colorIndices[2]],
d = colors[colorIndices[3]],
e = 1 - step,
f = Math.round(e * a[0] + step * b[0]),
g = Math.round(e * a[1] + step * b[1]),
h = Math.round(e * a[2] + step * b[2]),
i = "#" + (f << 16 | g << 8 | h).toString(16),
@arudmin
arudmin / read_sms.sh
Created August 8, 2014 11:19
Reading SMS from gammu folder
#!/bin/bash
DIR="/var/spool/gammu/inbox/*"
if [[ $1 == "-r" ]];
then
rm -rf $DIR
else
for f in $DIR
do
@arudmin
arudmin / syncthing
Last active June 8, 2019 17:44
/etc/init.d/syncthing script for Raspberry Pi (or any Ubuntu/Debian)
#!/bin/sh
### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
@arudmin
arudmin / macos.sh
Last active June 8, 2019 17:45
installing usefull packets for macos
#!/bin/bash
#install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install coreutils wget npm nodejs iftop htop p7zip
# du -h -d 1 / | gsort -hr
@arudmin
arudmin / keepassx-to-1passwords.py
Last active November 14, 2019 19:01
Convert exported XML file from KeepassX that could be imported to 1Password (via CSV comma separated file)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
from lxml import etree
import StringIO
import sys
reload(sys)
@arudmin
arudmin / .check_network.sh
Last active June 8, 2019 17:45
Reset wlan0 nttwork interface on Raspberry Pi
#!/bin/bash
ping -W 2 -c 1 8.8.8.8 > /dev/null
if [ $? -eq 0 ]; then
echo "online"
else
echo "offline"
logger -t [warn] “Internet connection lost. Trying to reload network interface”
sudo ifdown wlan0
sleep 3
@arudmin
arudmin / rpi.sh
Last active June 8, 2019 17:45
Raspberry Pi Starting Script
#!/bin/bash
echo "RASPBERRY PI UPDATING SCRIPT STARTED"
# Nginx Repo Add
sudo hostname -v pi
sudo localedef en_US.UTF-8 -i en_US -fUTF-8
sudo echo 'deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx' >> /etc/apt/sources.list
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key && rm nginx_signing.key
@arudmin
arudmin / imagemagick-nodejs.js
Created January 23, 2014 14:49
ImageMagick
// Require our module dependencies
var exec = require('child_process').exec;
// Create command array to invoke ImageMagick composite where
// -dissolve is the amount of transparency for the watermark
// -gravity tells how to align images of varying size
// -quality is the image quality of the JPEG (not required if producing PNG)
var command = [
'composite',
'-dissolve', '50%',