Skip to content

Instantly share code, notes, and snippets.

View lucassmagal's full-sized avatar

Lucas S. Magalhães lucassmagal

View GitHub Profile
@lucassmagal
lucassmagal / str.hs
Last active December 22, 2015 06:29
upperLetter, downLetter :: Char -> Char
upperLetter letter =
let ascii = fromEnum letter in
if ascii >= 97 && ascii <= 122
then toEnum (ascii - 32)
else letter
downLetter letter =
#!/bin/sh
export CUSTOM_VAR="It worked!"
echo "running shell"
exec "${@:-$SHELL}"
function foo(x) {
console.log('INSIDE FOO', x);
}
// 1
var myvar;
foo(myvar = 'some text');
if(!FOO.resources)
if(FOO.resources.fundos)
if(FOO.fragments)
if(FOO.fragments.legend_item)
if(FOO.state)
if(Object.keys(FOO.benchmarks).length == FOO.preloadable.benchmarks.length) {
return;
}
if (!(FOO.resources && FOO.resources.fundos
if(foo == 1 &&
bar == 2 &&
baz == 3) {
// do something
}
// é o mesmo de
if(foo == 1)
if(bar == 2)
if(baz == 3) {
function do_ajax(args, dfd, attempt) {
dfd || (dfd = $.Deferred());
attempt || (attempt = 1);
$.ajax(args).then(dfd.resolve, function(xhr, text_status, error_thrown) {
console.error('Fail on attempt', attempt + '!', 'Text status', text_status);
attempt++;
if(attempt > 3) {
dfd.reject(xhr, text_status, error_thrown);
$.ajax('...').done(function() {
angular.bootstrap(document, ['myapp']);
var app = angular.module('myapp', []);
});

Palestra boas práticas

Use o [modo restrito][1], sempre

// com modo restrito
function foo() {
    'use strict';

nome = 'Encatec';

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib64/python2.6/site-packages/newrelic-1.11.0.55/newrelic/api/object_wrapper.py", line 216, in __call__
self._nr_instance, args, kwargs)
File "/usr/lib64/python2.6/site-packages/newrelic-1.11.0.55/newrelic/hooks/framework_django.py", line 475, in wrapper
return wrapped(*args, **kwargs)
Environment:
Request Method: POST
Request URL: http://localhost:8000/admin/core/user/add/
Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',