Skip to content

Instantly share code, notes, and snippets.

View simonewebdesign's full-sized avatar
🇺🇦
💙 💛

Simone Vittori simonewebdesign

🇺🇦
💙 💛
View GitHub Profile
@simonewebdesign
simonewebdesign / .htaccess
Created March 8, 2014 21:12
My .htaccess (Apache configuration file)
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
@simonewebdesign
simonewebdesign / deploy.sh
Created April 19, 2014 15:08
Deploy a Jekyll site via LFTP
lftp -e 'mirror -R -e -v public; bye' -u user,pass ftp://ftp.example.com
@simonewebdesign
simonewebdesign / .htaccess
Created May 5, 2014 21:31
.htaccess redirect all requests to a subfolder
# /.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1 [L]
//
// ViewController.m
// Animation
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *image;
@property (strong, nonatomic) IBOutlet UILabel *label;
@simonewebdesign
simonewebdesign / replace.sql
Last active August 29, 2015 14:07
PostgreSQL regexp_replace example
CREATE OR REPLACE FUNCTION isFoo(text) RETURNS BOOLEAN AS '
SELECT $1 ~* ''insert_regex_here'' AS RESULT
' LANGUAGE SQL;
UPDATE blocks
SET content=(SELECT regexp_replace(content, 'insert_regex_here', 'insert_replace_text_here'));
;--WHERE isFoo(content);
SELECT *
FROM blocks
@simonewebdesign
simonewebdesign / ajax-spec.js
Created February 24, 2015 09:50
Chai expectations and Sinon.js (test spies) example checking if an object contains a certain key/value pair
it('will POST data in JSON format', () => {
let promise = ajax('POST', '/somewhere', {foo: "bar"})
.then((result) => {
expect(result).to.equal('OK');
});
expect(requests[0].requestBody).to.equal(JSON.stringify({foo: "bar"}));
requests[0].requestHeaders.should.have.property("Content-Type").with.length("application/json;charset=utf-8".length);
assert.propertyVal(requests[0].requestHeaders, "Content-Type", "application/json;charset=utf-8");
expect(requests[0].requestHeaders).to.have.property("Content-Type", "application/json;charset=utf-8");
requests[0].respond(200, {}, 'OK');
@simonewebdesign
simonewebdesign / es6.js
Created March 6, 2015 15:44
Playing around with ES6
let foo = 'bar';
let fn = () => "baz";
console.log(foo);
console.log(fn());
let log = msg => console.log(msg)
log(foo);
@simonewebdesign
simonewebdesign / eventDispatcher.js
Last active August 29, 2015 14:17
Create and dispatch an event
function createAndDispatchEvent(eventName, target) {
var e = document.createEvent("HTMLEvents");
e.initEvent(eventName, true, true);
target.dispatchEvent(e);
}
@simonewebdesign
simonewebdesign / foo.html.haml
Last active August 29, 2015 14:20
Fetching a RESTful resource in AngularJS (CoffeeScript)
%div{'ng-controller' => 'FooCtrl as foo'}
this is the content
%button{'ng-click' => 'foo.bar()'} Call bar()
%div{'ng-repeat' => 'report in foo.reports'}
this is one report: {{ report.reference }} {{ report.bar }}
@simonewebdesign
simonewebdesign / example.sh
Last active August 29, 2015 14:25
Search and replace (sort of templating engine) in Bash
echo this is a test, then. | ./bin/post-build.sh --this that --then doo
that is a test, doo.