Skip to content

Instantly share code, notes, and snippets.

/* normal flexbox */
.flexbox .flex-container {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: flex;
}
.flexbox .flex-container.vertical {
display: -webkit-flex;
display: -moz-flex;
@Lazerproof
Lazerproof / ie_detect
Created January 19, 2016 04:47
Javascript IE detection
function isIE () {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}
if ( isIE () < 9 ) {
//is IE version less than 9
} else{
// Other versions IE or not IE
}
Less css trick to generate BEM-styled selectors, by Max Shirsin, http://noteskeeper.ru/1139 + Scss version
@block: ~".dm-import-feed";
@{block} {
&_step_2 {
@{block}__page_step_2 {
display: block;
}
}
@Lazerproof
Lazerproof / json.md
Last active March 17, 2016 17:51
JSON API for Terrans

JSON API for Terrans

Motivation

Therea are a lot of REST API implementations. And it is always takes a lot of time to decide what to use. For example, should we use unix time or ISO8601? How foreign keys should be handled? How to return errors? etc.

This document just describes practices that works good in production. REST API should be intuitive and understandable without reading tons of docs. Several years ago we started using jsonapi.org but it is rather unstable and every time when I visit jsonapi.org I understand that everything written before is not compatible with newer version.

Moreover, jsonapi.org becomes too complex. We call it jsonapi for Zergs. In our company we prefer to use jsonapi for Terrans :). This document describes it. Everything is written in document is just recomendation no "MUST", use common sense for edge cases.

@Lazerproof
Lazerproof / search-form.php
Created March 22, 2016 11:21 — forked from outflux3/search-form.php
Processwire sample search form based on skyscrapers search
<form name='search' id='product-search' method='get' action='<?php echo $config->urls->root?>speaker-finder/'>
<ul id="row1">
<li>
<label for='search_app'>Application</label>
<select id='search_app' name='application' onchange="$(this.form).trigger('submit')">
<option value=''>Any</option><?php
// generate the application options, checking the whitelist to see if any are already selected
foreach($pages->get(1016)->children('include=all') as $app) {
$selected = $app->name == $input->whitelist->application ? " selected='selected' " : '';
@Lazerproof
Lazerproof / search-processor.php
Created March 22, 2016 11:23 — forked from outflux3/search-processor.php
search-processor. processwire
<?php
// check if there are GET variables present in the URL
if(count($input->get)) {
$selector = '';
if($input->get->application) {
$application = $sanitizer->pageName($input->get->application);
$appid = $pages->get("template=product-options, name=$application");
@Lazerproof
Lazerproof / contact-form.php
Created March 22, 2016 12:16 — forked from MatthewSchenker/contact-form.php
ProcessWire form with "regular" fields and file uploads. The first two files (contact-form and contact-success) are for the contact form and the success page with normal fields. This works successfully. The third and fourth files (contact-form2 and contact-success2) are the same, but with the file-upload field added. These are currently not work…
<form action="/customer-service/contact/contact-success/" method="post">
<p><label for="contactname">Name:</label></p>
<p><input type="text" name="contactname"></p>
<p><label for="email">E-Mail:</label></p>
<p><input type="email" name="email"></p>
<p><label for="comments">Comments:</label></p>
<p><textarea name="comments" cols="25" rows="6"></textarea></p>
<button type="submit">Submit</button>
</form>
@Lazerproof
Lazerproof / pw_buid-form.php
Created March 22, 2016 12:20 — forked from ocorreiododiogo/pw_buid-form.php
For Processwire. Mirror admin forms in the frontend. Works well with regular fields (text, textareas, checkboxes, radios, multiple choice, etc), but didn't manage to make it work well with images
<?php
// Get the page you need to edit
$mypage = $pages->get('/some/page/');
// Populate with the names of the fields you want to exclude OR include (see instructions below)
// Leave empty to output all the fields
$myfields = array('body', 'email');
$form = $modules->get('InputfieldForm');
$fields = $mypage->getInputfields();
var gulp = require('gulp');
var bs = require('browser-sync').create();
var runSequence = require('run-sequence');
var connect = require('gulp-connect-php');
gulp.task('php', function() {
php.server({
base: './app',
port: 8001,
}, function (){
<?php
// Init vars
$out = '';
// Temp upload path for file uploads
$upload_path = $config->uploadTmpDir;
// create form
$form = $modules->get("InputfieldForm");