Skip to content

Instantly share code, notes, and snippets.

View romuloctba's full-sized avatar
:octocat:

RcDev romuloctba

:octocat:
View GitHub Profile
@romuloctba
romuloctba / iosfix.js
Created April 14, 2015 13:59
Fix for iOS6 timer erasing problem that breaks timers when they are created while scrolling
// This code is free to use by anyone (MIT, blabla).
// Original Author: [email protected] *uncompressed code @ gist ronkorving/3755461
!function(e){function n(n,t,r){function a(){c&&(c.apply(e,arguments),l||(delete t[i],c=null))}var i,c=r[0],l=n===o;return r[0]=a,i=n.apply(e,r),t[i]={args:r,created:Date.now(),cb:c,id:i},i}function t(n,t,r,a){function i(){c.cb&&(c.cb.apply(e,arguments),l||(delete r[a],c.cb=null))}var c=r[a];if(c){var l=n===o;if(t(c.id),!l){var u=c.args[1],d=Date.now()-c.created;0>d&&(d=0),u-=d,0>u&&(u=0),c.args[1]=u}c.args[0]=i,c.created=Date.now(),c.id=n.apply(e,c.args)}}var r={},a={},i=e.setTimeout,o=e.setInterval,c=e.clearTimeout,l=e.clearInterval;if(!e.addEventListener)return!1;e.setTimeout=function(){return n(i,r,arguments)},e.setInterval=function(){return n(o,a,arguments)},e.clearTimeout=function(e){var n=r[e];n&&(delete r[e],c(n.id))},e.clearInterval=function(e){var n=a[e];n&&(delete a[e],l(n.id))};for(var u=e;u.location!=u.parent.location;)u=u.parent;u.addEventListener("scroll",func
@romuloctba
romuloctba / functions.php
Created April 14, 2015 15:06
Add post thumbnail to wp-admin columns
<?php
add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
function posts_columns($defaults){
$defaults['thethumbs'] = __('Featured Image'); //name it here.
return $defaults;
}
function posts_custom_columns($column_name, $id){
@romuloctba
romuloctba / assinar-apk.md
Created June 11, 2015 04:19
Colinha para assinar e publicar .apk

Para assinar apk:

  1. ionic build --release android vai gerar um apk na pastaDoProjeto/platforms/android/build/output/android-unsigned.apk. Renomeie o arquivo para nomeDoApk-unsigned.apk

  2. Na pasta do java/jde-AlgumaVersao/bin: keytool -genkey -v -keystore nomeDaChave.keystore -alias aliasQueVcEscolhe -keyalg RSA -keysize 2048 -validity 1000

  3. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore nomeDaChave.keystore nomeDoApk-unsigned.apk aliasQueVcEscolheu

  4. na pasta do android-adt/sdk/build-tools/algumaVersao: zipalign -v 4 nomeDoApk-unsigned.apk nomeQueVcQuerDarParaOApk.apk

  5. Prontinho. Preencha tudo e tire os prints para o Google Play Developer Console, envie o Apk. `

@romuloctba
romuloctba / functions.php
Created August 24, 2015 12:19
Woo Commerce - redirect to checkout when add to cart
/**
* Redirect user to checkout page directly after adding to cart
*
* @return string
*/
function wc_redirect_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url();
return $checkout_url;
}
<?php
/**
* Use * for origin
*/
add_action( 'rest_api_init', function() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' );
@romuloctba
romuloctba / countriesArray
Last active September 24, 2015 14:23 — forked from DHS/PHP Countries Array
Javascript array of all country names
var countries = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvin
@romuloctba
romuloctba / limitBounds.js
Last active November 8, 2015 14:44
Limit google Maps bound pan
// http://stackoverflow.com/a/30402221/1576978
//Add this eventListener to your map's initialize() function:
google.maps.event.addListenerOnce(map, 'bounds_changed', boundLimiter);
function boundLimiter(){
// bounds of the desired area -> 1st: SW, 2nd: NE
var allowedBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(70.33956792419954, 178.01171875),
new google.maps.LatLng(83.86483689701898, -88.033203125)
);
@romuloctba
romuloctba / arduino-temperature.ino
Created October 2, 2015 19:01 — forked from dansku/arduino-temperature.ino
Arduino LM35 Example
/*
An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular basis
(cc) by Daniel Spillere Andrade , http://www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
@romuloctba
romuloctba / howto.md
Created October 3, 2015 23:13
Hot to remove extra blank lines on files

How to Remove extra blank lines on files

Simple, just do a search and replace using regex.

At Sublime Text, just ctrl+h and click the Regular Expression icon (The first on the left, like the Sum Symbol)

  • Find What: [\r\n]{2,}
  • Replace With: \n
@romuloctba
romuloctba / isUrl.js
Created October 14, 2015 13:03
Javascript Regex Function to validate URL
function ValidURL(str) {
var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
if(!regex .test(str)) {
return false;
} else {
return true;
}
}