Skip to content

Instantly share code, notes, and snippets.

View dflima's full-sized avatar
📱
developing stuff

Danilo dflima

📱
developing stuff
View GitHub Profile
@dflima
dflima / insert_time.py
Created June 19, 2013 18:01
Sublime Text plugin to insert current datetime
import sublime, sublime_plugin, datetime
class InsertTimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
date_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
for r in self.view.sel():
self.view.replace(edit, r, date_time)
jQuery.fn.disable = function(){
return this.each(function(){
if(typeof this.disabled != "undefined") this.disabled=true
});
}
@dflima
dflima / is_json.php
Last active December 23, 2015 12:59
Verify if a given $string is a json.
<?php
function is_json($string)
{
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
@dflima
dflima / email_validation.php
Created October 4, 2013 21:17
Email validation
<?php
function validate_email($email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL))
return true;
return false;
}
var_dump(validate_email("me@example.com"));
@dflima
dflima / Preferences.sublime-settings
Created November 26, 2013 13:30
My Sublime Text 3 settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 10,
"caret_style": "wide",
"highlight_line": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"fade_fold_buttons": false,
"ignored_packages":
[
@dflima
dflima / git_log
Created December 3, 2013 12:27
Pretty git log screen. Source: https://coderwall.com/p/euwpig
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Adicionando o repositório:

$ sudo add-apt-repository ppa:webupd8team/java

Caso esse comando não seja encontrado:

$ sudo apt-get install software-properties-common python-software-properties
syntax on
set background=dark
set colorcolumn=120
set encoding=utf-8
set expandtab
set hidden
set laststatus=2
set listchars=eol:⏎,tab:>-,trail:⌀,extends:>,precedes:<,conceal:-,nbsp:.
set nolist
set number
package main
import "fmt"
func ReadParams(size int) (params []int) {
var param int
for i := 0; i < size; i++ {
_,err := fmt.Scanf("%d", &param)
if err == nil {
params = append(params, param)
package main
import "fmt"
type person struct {
age int
}
func (p person) NewPerson(initialAge int) person {
//Add some more code to run some checks on initialAge
if initialAge <= 0 {