Skip to content

Instantly share code, notes, and snippets.

View wwwjsw's full-sized avatar
:octocat:
Working from home since 2019

guilherme wwwjsw

:octocat:
Working from home since 2019
  • Brazil
  • 23:26 (UTC -03:00)
View GitHub Profile
henrique@henrique-Inspiron-3647:~/Desktop$ sudo apt-get update
[sudo] password for henrique:
Ign:1 http://us.archive.ubuntu.com/ubuntu yakkety InRelease
Ign:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates InRelease
Ign:3 http://us.archive.ubuntu.com/ubuntu yakkety-backports InRelease
Ign:4 http://us.archive.ubuntu.com/ubuntu yakkety-security InRelease
Ign:5 http://us.archive.ubuntu.com/ubuntu yakkety Release
Ign:6 http://us.archive.ubuntu.com/ubuntu yakkety-updates Release
Ign:7 http://us.archive.ubuntu.com/ubuntu yakkety-backports Release
Ign:8 http://us.archive.ubuntu.com/ubuntu yakkety-security Release

multiple 'events listeners'

var elems = [view1,view2,button1];
var events = ['touch','singletap','myownevent'];
for (var el=0;el< elems.length; el++) {
  for (var ev=0; ev < events.length; ev++ ) {
    elems[i].addEventListener(events[ev],callbackfunction);
  }
} 
@wwwjsw
wwwjsw / slugify.php
Last active February 23, 2017 11:47
<?php
static public function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
function encrypt($key, $plain_text) {
$plain_text = trim($plain_text);
$iv = substr(md5($key), 0, mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB));
$c_t = mcrypt_cfb(MCRYPT_CAST_256, $key, $plain_text, MCRYPT_ENCRYPT, $iv);
return trim(chop(base64_encode($c_t)));
}
function decrypt($key, $c_t) {
$c_t = trim(chop(base64_decode($c_t)));
$iv = substr(md5($key), 0, mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB));
window.onload = function() {
var heading = document.createElement("h1");
var heading_text = document.createTextNode("Big Head!");
heading.appendChild(heading_text);
document.body.appendChild(heading);
}
//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 5000; //time in ms, 5 second for example
var $input = $('#myInput');
//on keyup, start the countdown
$input.on('keyup', function () {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
//RECONHECE SE É UM LINK (COMEÇANDO COM HTTPS, HTTP OU WWW)
preg_match('/^(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/', 'http://i.imgur.com/X7QXj8S.jpg')
@wwwjsw
wwwjsw / codeigniter_param_route.php
Created July 24, 2017 19:19
Any parameter can be pass to index controller
<?php
$route['(:any)'] = 'home/index/$1';
<?php
$start = new DateTime('-7 days', new DateTimeZone('UTC'));
$period = new DatePeriod($start, new DateInterval('P1D'), 7);
foreach ($period as $date) {
echo $date->format('D d-m-Y').'<br>';
}
import UIKit
import Kingfisher
//DEFINE A ESTRUTURA DA NOTICIA
struct Noticia : Decodable {
var noticias_id : String
var cidade : String
var titulo : String