Skip to content

Instantly share code, notes, and snippets.

@jhonsore
jhonsore / Hamburguer menu.markdown
Created December 29, 2015 17:58
Hamburguer menu
@jhonsore
jhonsore / String_to_func.js
Last active September 2, 2016 14:30
String to function in javascript
// function name and parameters to pass
var fnstring = "customFunc";
var fnparams = [1, 2, 3];
// find object
var fn = window[fnstring];
// is object a function?
if (typeof fn === "function") fn.apply(null, fnparams);
@jhonsore
jhonsore / gist:9be20f3ca3d4745e46e5
Last active January 26, 2016 12:27
Return a query string from url
var QueryString = function ()
{
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
{
@jhonsore
jhonsore / gist:524b7821c431a39fb2ab
Created January 26, 2016 13:40
Converts ANSI characters to UTF-8
//Converte sequência de caracteres ANSI para UTF-8 e vice-versa.
//http://jsfromhell.com/pt/geral/utf-8
var UTF8 = {
encode: function(s){
for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
);
return s.join("");
},
decode: function(s){
@jhonsore
jhonsore / gist:226abac3d974c0118963
Created January 26, 2016 13:40
Returns variable type in js
var types = {
'get': function(prop) {
return Object.prototype.toString.call(prop);
},
'object': '[object Object]',
'array': '[object Array]',
'string': '[object String]',
'boolean': '[object Boolean]',
'number': '[object Number]'
}
@jhonsore
jhonsore / box-shadow.html
Created January 29, 2016 13:13 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
#parent{
height: 100%;
width: 100%;
overflow: hidden;
}
#child{
width: 100%;
height: 100%;
overflow: auto;
@jhonsore
jhonsore / gist:86e2ee516b48ba95e0ef
Created February 9, 2016 19:48
Simple input field in ios
NSString *roboto_font = @"Roboto-Regular";
UITextField *input_login = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
input_login.alpha = 0.1f;
input_login.textAlignment = NSTextAlignmentCenter;
input_login.textColor = [UIColor whiteColor];
input_login.layer.shadowColor = [[UIColor blackColor] CGColor];
input_login.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
input_login.layer.shadowOpacity = 1.0f;
input_login.layer.shadowRadius = 1.0f;
input_login.font = [UIFont fontWithName:roboto_font size:15];
//source: https://coderwall.com/p/zz5ieg/rgb-to-uicolor
#define rgb(R,G,B) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:1.0]
#define rgba(R,G,B,A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A]
mylabel.textColor = rgb(231, 76, 60);
myview.backgroundColor = rgba(231, 76, 60,0.2);
// Alpaha value max is 1 and min is 0 , you must use float point
@jhonsore
jhonsore / gist:ffd6d0ea576f0ca2d4bb
Last active February 9, 2016 21:10
Dismiss keyboard in IOS
//Add UITextFieldDelegate in Controller
@interface ViewController : UIViewController<UITextFieldDelegate>
UITapGestureRecognizer *tapRecognizer;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow:) name:
UIKeyboardWillShowNotification object:nil];