Skip to content

Instantly share code, notes, and snippets.

View leobossmann's full-sized avatar

Leo Bossmann leobossmann

  • noni Mode GmbH
  • Cologne, Germany
View GitHub Profile
@leobossmann
leobossmann / gist:4723027
Created February 6, 2013 14:52
console.log replacent for incapable browsers
if(!(typeof console).match(/object/i)){
console = { log : function(a){ alert(a) } };
}
@leobossmann
leobossmann / gist:5344769
Created April 9, 2013 10:46
Enable SMTP Relay for domainfactory fixes bug: status=deferred (SASL authentication failed; cannot authenticate to server smtprelaypool.ispgateway.de[80.67.29.4]: no mechanism available)
In /Library/Server/Mail/Config/postfix/main.cf add line:
smtp_sasl_security_options = noanonymous
<snippet>
<content><![CDATA[{% include '__localize' with 'l10n-${SELECTION/([a-zA-Z]+)(?:(\s+?)|\b)/?1:\L$1(?2:-)\E/g}' %}]]></content>
<description>Wrap String in localization helper</description>
</snippet>
@leobossmann
leobossmann / gist:5998424
Created July 15, 2013 08:41
Dump rails database to a remote location, strip schema migrations
mysqldump --skip-triggers --compact --no-create-info --complete-insert -u [db_user] -p [db_name] | sed '/schema_migrations/d' | gzip -c | ssh [remote_user]@[remote_host] 'cat > [remote_file].sql.gz'
@leobossmann
leobossmann / clone shopify checkout locale
Last active November 7, 2017 18:26
Shamelessly copy a checkout translation in the Shopify backend.
When logged in, go to "Settings > Checkout > Checkout Language", click the "View and customize this translation" link.
A page with a url like this opens: "https://yourshop.myshopify.com/admin/settings/locales/[locale_id]".
copy [locale_id].
Go Back and choose "create a new one".
Open the Javascript console, paste this (change to your shop/locale_id first):
@leobossmann
leobossmann / bulk import shipping rates
Created July 23, 2013 20:36
Bulk create/delete shipping rates in the Shopify backend. Go to Settings/Shipping and paste it into Javascript console. WARNING: This is a proof of concept, use with extreme caution and only if you know what you're doing, you will have to customize this to fit your needs. Again, just a proof of concept, worked for me, might not work for you. Ong…
function make_shipping_rates(id, low, mid, high) {
$.post('/admin/price_based_shipping_rates.json', {
price_based_shipping_rate: {
country_id: id,
min_order_subtotal: "0",
max_order_subtotal: "500",
name: "DHL Premiumversand",
offsets: [],
price: low
}
@leobossmann
leobossmann / gist:6535575
Created September 12, 2013 10:37
.htaccess-rule to redirect if request is not from the defined IP
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$
RewriteCond %{REMOTE_HOST} !^123\.234\.345\.456$
RewriteRule ^(.*)$ http://www.domain2.com/$1 [L,R=302]
@leobossmann
leobossmann / gist:6608883
Created September 18, 2013 13:05
List all GUIDs of users on a OS X Server
From: https://discussions.apple.com/thread/4029413?start=0&tstart=0
For the local directory
dscl . -list /Users GeneratedUID
For a shared directory
dscl /LDAPv3/127.0.0.1 -list /Users GeneratedUID
@leobossmann
leobossmann / gist:cf57b6851313e0d8588a
Created August 14, 2014 05:31
How to reboot cheap Chinese ipcam from command line
this works on openWRT:
{ echo -e "user\r"; echo -e "pass\r"; echo -e "reboot"; sleep 1; } | telnet ip.address.of.ipcam port
on Linux/OSX you get away without the -e and \r, but busybox' telnet client needs them:
{ echo "user"; echo "pass"; echo "reboot"; sleep 1; } | telnet ip.address.of.ipcam port
My cam is so well-made, it actually works with "admin" and "pass" literally, on port 88
@leobossmann
leobossmann / check_traffic.sh
Created August 14, 2014 14:10
Get cumulated traffic usage from webalizer stats, send email if over limit
#!/bin/bash
LIMIT=45000000
USAGE=0
for dir in /path/to/stats/*/
do
LOCAL_USAGE=`head -n 2 $dir/webalizer.hist | tail -n 1 | cut -d" " -f6`
USAGE=$(($USAGE + $LOCAL_USAGE))
done