Skip to content

Instantly share code, notes, and snippets.

View Swader's full-sized avatar
🏠
Buidling

Bruno Škvorc Swader

🏠
Buidling
View GitHub Profile
@Swader
Swader / manifest-new.js
Created November 7, 2012 14:17
Codeskulptor Autosave - Fancy Settings Manifest JS
window.manifest = {
"name": "Codeskulptor Autosave",
"icon": "../../icon48.png",
"settings": [
{
"tab": "Main settings",
"group": "Frequency settings",
"name": "freq",
"type": "slider",
"label": "Frequency in minutes:",
@Swader
Swader / background.js
Created November 7, 2012 14:14
Codeskulptor Autosave - Background JS
var settings = new Store("settings", {
"freq": 3
});
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
chrome.pageAction.show(sender.tab.id);
sendResponse(settings.toObject());
}
);
@Swader
Swader / irishAwesomeness.js
Created November 11, 2012 23:35
Paul Irish's Javascript Tricks from jQuery 1.4.2
// Paul Irish dissects jQuery's source code and explains some sexy practices and pitfalls. Here's a summary.
// This pattern is a self-executing anonymous function. It helps minification, faster scope access to document and eliminates the asshole effect where someone writes undefined = true in your JS
(function(window, document, undefined){
/*... code here ...*/
})(this, document);
// In short, the self calling pattern is as follows:
(function f() {})();
// or with arguments
@Swader
Swader / manifest.json
Created November 20, 2012 00:01
DeSkin - manifest.json
{
"name": "DeSkin",
"version": "0.9",
"manifest_version" : 2,
"description": "Hides Vevo ads from around Youtube videos",
"background" : { "page" : "background.html" },
"page_action" :
{
"default_icon": {
"19": "icons/19.png",
@Swader
Swader / background.js
Created November 20, 2012 00:04
DeSkin - background.js
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
chrome.pageAction.show(sender.tab.id);
sendResponse({});
});
@Swader
Swader / main.js
Created November 20, 2012 00:06
DeSkin - main.js
// These are the elements that get force-fed ad styles
var ids = new Array("watch-headline-show-title", "watch-headline-title", "content");
// Cache the array count to get the fastest looping
var idsCount = ids.length;
// Loop through every one of those IDs and..
while(idsCount--) {
// Fetch the element by current ID
var element = document.getElementById(ids[idsCount]);
@Swader
Swader / notices_article_01.php
Created December 7, 2012 09:58
notices_article_01
<?php
$aArray = array();
$aArray['someKey'];
?>
// Notice: Undefined index: someKey in ...
@Swader
Swader / notices_article_03.php
Created December 7, 2012 10:17
notices_article_03
<h1>Operation completed</h1>
<?php
echo @$this->aMessages['error'];
echo '<hr />';
echo $this->aMessages['status'];
echo '<hr />';
// ...
@Swader
Swader / notices_article_02.php
Created December 7, 2012 10:10
notices_article_02
// $oView = ... our view object
if (/* some expression that signifies an error */) {
$aMessages['error'] = 'Error no.2 occurred, contact developer!';
}
$aMessages['status'] = 'Finished operation';
$oView->aMessages = $aMessages;
@Swader
Swader / notices_article_04.php
Created December 7, 2012 11:25
notices_article_04
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
echo "<b>ERROR!</b> [$errno] $errstr<br />\n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
echo "Aborting...<br />\n";