Skip to content

Instantly share code, notes, and snippets.

Avatar

Arudmin arudmin

  • Russia
View GitHub Profile
@arudmin
arudmin / images_as_url.ocmod.xml
Last active May 7, 2018
images_as_url.ocmod.xml
View 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 Nov 25, 2018
allows to import images as URL to opencart
View image.php
// 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 Aug 29, 2015
js-fade-gradient
View fade-gradient.js
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 Aug 8, 2014
Reading SMS from gammu folder
View read_sms.sh
#!/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 Jun 8, 2019
/etc/init.d/syncthing script for Raspberry Pi (or any Ubuntu/Debian)
View syncthing
#!/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 Jun 8, 2019
installing usefull packets for macos
View macos.sh
#!/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 Nov 14, 2019
Convert exported XML file from KeepassX that could be imported to 1Password (via CSV comma separated file)
View keepassx-to-1passwords.py
#!/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 Jun 8, 2019
Reset wlan0 nttwork interface on Raspberry Pi
View .check_network.sh
#!/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 Jun 8, 2019
Raspberry Pi Starting Script
View rpi.sh
#!/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
View imagemagick-nodejs.js
// 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%',
You can’t perform that action at this time.