Skip to content

Instantly share code, notes, and snippets.

Just open xcode and hit: (cmd + shift + k)
@jhonsore
jhonsore / getPath.js
Last active November 7, 2017 12:28
Returns an array from the url path in browser
function getPath (__args__){
var path = window.location.pathname;
path = path.split("/");
var newPath = [];
path.forEach(function(element, index, array){
if(__args__ && __args__.replace){
var _index = __args__.replace.indexOf(element);
if(_index < 0 && element != ''){
newPath.push(element);
@jhonsore
jhonsore / scripts.js
Created October 28, 2017 09:21
contenteditable in webview (iOS/android)
var _el = $("#my-element");
//instantiate the thumbowyg for WYSIWYG editor
$(_el).trumbowyg()
.on('tbwinit', function(){
//when click occurs on element, we give a focus to it
$('.trumbowyg-editor').click(function(){
$(this).focus();
});
//if return key is pressed we add a break line on it
callElementEditable ();
@jhonsore
jhonsore / gulpfile.js
Created October 12, 2017 14:58
Less sprite + gulp implementation
var gulp = require('gulp');
var spritesmith = require('gulp.spritesmith');
/**
* A seguinte tarefa buscará arquivos com extensão .png no diretório de sprites, dentro de img/
* É importante dizer que será criado um css contendo as classes para o uso dos sprites.
* O formato da criação das classes é dado pela propriedade cssVarMap juntamente com cssOpts.cssSelector
* Podemos perceber que a classe é formada por .spt-<nome-arquivo>
* Após a criação tanto do sprite quanto do css, eles são movidos para as pastas necessárias.
*/
gulp.task('sprite', function() {
@jhonsore
jhonsore / README.md
Last active November 9, 2022 03:07
[DEPRECATED] Upload an Image from camera or gallery in WebView.

This is an old way to Upload an Image from camera or gallery in WebView. It was made a long time ago and is not maintened anymore. Use it at your own risk.

//php array
$data = array(
array("key1"=>"value"),
array("key2"=>"value 2")
);
//twig template
{% for value in data %}
{% for key in value|keys %}
@jhonsore
jhonsore / url_slug.php
Created February 2, 2017 02:17
Url slug SEO friendly
public static function url_slug($string, $slug = false)
{
//$string = strtolower(strip_tags($string));
// Código ASCII das vogais
$ascii['a'] = range(224, 230);
$ascii['e'] = range(232, 235);
$ascii['i'] = range(236, 239);
$ascii['o'] = array_merge(range(242, 246), array(240, 248));
$ascii['u'] = range(249, 252);
https://google-webfonts-helper.herokuapp.com/
@jhonsore
jhonsore / sprite.less
Created January 6, 2017 09:32
Generate sprite customizations for gulp-sprites with mobile background size
/*************************************/
.sprites-gulp-mobile(@spritesheet-sprites);
/*************************************/
.sprite-width-gulp-mobile(@sprite) {
width: extract(@sprite, 5)/2;
}
.sprite-height-gulp-mobile(@sprite) {
height: extract(@sprite, 6)/2;
@jhonsore
jhonsore / gulp.js
Created January 6, 2017 03:44
Sprite image with gulp
var gulp = require('gulp');
var spritesmith = require('gulp.spritesmith');
/**
* The task will search for all files with .png extension in directory sprites/ inside img/
* The class name will be .spt-<file name>
* After created the files are moved to the folders
*/
gulp.task('sprite', function() {
var spriteData =
gulp.src('img/sprites/*.png')