This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Originally posted on: https://rubdotto.com/clean-code-desinformaci%C3%B3n/ | |
findDragonBall() | |
findDragonBalls() | |
findDragonBells() | |
findDragonWithBalls() | |
findDragonWithBalletSlippers() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Originally posted on: https://rubdotto.com/clean-code-nombre-de-variables/ | |
public boolean isSS(int r, int hc, int e) { | |
if (r != 3) { | |
return false; | |
} | |
if (hc != 0xFFFFFF00) { | |
return false; | |
} | |
if (e < 1000000) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_dict_extract(node, kv): | |
if isinstance(node, list): | |
for i in node: | |
for x in gen_dict_extract(i, kv): | |
yield x | |
elif isinstance(node, dict): | |
if kv in node: | |
yield node[kv] | |
for j in node.values(): | |
for x in gen_dict_extract(j, kv): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING, this code doesn't work, is an example of usage | |
val json = JSONObject() | |
json.safeGetString("property")?.let { | |
// Do awesome things with property value | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works with Awesome Console IntelliJ plugin | |
// https://plugins.jetbrains.com/plugin/7677-awesome-console | |
import timber.log.Timber // https://github.com/JakeWharton/timber | |
class AwesomeTimberLog { | |
fun doLogWithLinkToSourceCode() { | |
Timber.d("Hello World! - " + UtilsK.getLinkToSourceFile(Thread.currentThread().stackTrace[2])) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create image resuource, use 'imagecreate*' that you need | |
$im = imagecreatefromstring($img_string); | |
imagesavealpha($im, true); | |
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127); // transparent background | |
imagefill($im, 0, 0, $trans_colour); | |
$text_color = imagecolorallocatealpha($im, 0, 0, 0, 126); // almost transparent text color "not visible human eye" | |
imagestring($im, 1, 0, 0, "UNIQUE_ID", $text_color); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php -d suhosin.executor.include.whitelist="phar" go-pear.phar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set Cache | |
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; | |
[NSURLCache setSharedURLCache:sharedCache]; | |
//Clear All Cookies | |
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { | |
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function str_var_dump($object) | |
{ | |
ob_start(); | |
var_dump($object); | |
$dump = ob_get_clean(); | |
return $dump; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function log_database_error($last_query, $error_message, $error_number, $data = null) | |
{ | |
log_message('debug', __METHOD__); | |
if ($data) { | |
log_message('error', "data: " . $this->str_var_dump($data)); | |
} | |
log_message('error', "query: " .$last_query); | |
log_message('error', "DB Error: ".$error_message." (ERR_NUM: ".$error_number.")"); | |
} |
NewerOlder