Skip to content

Instantly share code, notes, and snippets.

View VadimBrodsky's full-sized avatar

Vadim Brodsky VadimBrodsky

View GitHub Profile
@VadimBrodsky
VadimBrodsky / prefs.js
Created January 25, 2018 03:24 — forked from jonchurch/prefs.js
Dracula theme for Chrome Secure Shell, for all of us using crouton!
// Paste this whole file into your Chrome Secure Shell window's inspect console, and run it!
term_.prefs_.set('enable-bold', false)
term_.prefs_.set('background-color', "#282a36");
term_.prefs_.set('foreground-color', "#f8f8f2");
term_.prefs_.set('color-palette-overrides', [
"#000000",
"#ff5555",
"#50fa7b",
@VadimBrodsky
VadimBrodsky / RPi: Syncthing + start on boot
Created October 8, 2016 19:23
How to install Syncthing on Raspberry Pi + start on boot
Create a folder in /opt and cd to it
$ sudo mkdir -p /opt/syncthing
$ cd /opt/syncthing
Get the latest arm version of syncthing from github (https://github.com/syncthing/syncthing/releases/) x marks the version number.
$ sudo wget https://github.com/syncthing/syncthing/releases/download/vx.xx.x/syncthing-linux-arm-vx.xx.x.tar.gz
sudo tar -xzvf syncthing-linux-arm-vx.xx.x.tar.gz
sudo rm syncthing-linux-arm-vx.xx.x.tar.gz
Move content one folder up
@VadimBrodsky
VadimBrodsky / .htaccess
Created April 28, 2016 15:40 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@VadimBrodsky
VadimBrodsky / IRR.js
Created February 3, 2016 20:15 — forked from ghalimi/IRR.js
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@VadimBrodsky
VadimBrodsky / friendly_urls.markdown
Created December 16, 2015 03:20 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

// Bonfire: Find the Longest Word in a String
// Author: @vadimbrodsky
// Challenge: http://www.freecodecamp.com/challenges/bonfire-find-the-longest-word-in-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function findLongestWord(str) {
return str.toLowerCase().split(' ').sort(function(a, b) {
if (a.length < b.length) {
return 1;
} else if (a.length > b.length) {
@VadimBrodsky
VadimBrodsky / db-connect-test.php
Last active August 29, 2015 14:27 — forked from chales/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@mixin clearfix-micro() {
& {
*zoom: 1;
}
&:before,
&:after {
content: "";
display: table;
}
&:after {

Templating in EE vs. Craft

Lots of people have asked, so here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft.

Table of Contents

  1. Comments
  2. Conditionals
  3. Loops

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000