Skip to content

Instantly share code, notes, and snippets.

@jsolid
jsolid / hide-show-div-when-element-clicked.html
Created September 7, 2012 00:38
Hide/Show DIV when element is clicked
<form id="sForm" name="sForm" method="POST">
<!-- DIV containing textfield, always display -->
<div id="inside" name="inside" class="inside">
<input type="text" id="searchText" name="searchText" maxlength="25" placeholder="search for games" autocomplete="off" tabindex="1" style="z-index:500" />
</div>
<!-- DIV of wrapping block -->
<div id="outside" name="outside" class="outside hidden">
<div class="hd">
<div id="closeBtn" name="closeBtn" class="right btnClose">X</div>
@jsolid
jsolid / gradient-button.css
Created September 7, 2012 06:13
Gradient button
.button {
display: inline-block;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em; /* Change values for different sizes */
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
@jsolid
jsolid / form-control.js
Created September 17, 2012 04:46
Display confirmation dialog before exiting/refreshing current page
var processDialog = new YAHOO.widget.Dialog('procDialog', {
width: '400px',
height: '350px',
underlay: 'shadow',
visible: false,
modal: true,
});
window.onbeforeunload = (function() {
if ( processDialog.cfg.getProperty('visible') &&
@jsolid
jsolid / moving-fonts.html
Created September 21, 2012 01:35
Move fonts in parallax effect
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Moving Fonts</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="plax.js"></script>
<style type="text/css">
* {
padding: 0;
@jsolid
jsolid / MyMailMessage.cpp
Last active May 23, 2020 03:55
POCO library: Calling from .cpp
/**
* @name EmailInbound (Mail Message Handler for POCO)
* @description Receive and sort emails
*/
#include "MyMailMessage.h"
/**
* POCO::Net::MailMessage
*/
@jsolid
jsolid / badge.php
Created October 26, 2012 04:43
PHP - Achievement event trigger
class Badge {
public function __construct() {
// Define all the achievements
Events::register('badges', array($this, 'badgeCommentator'));
Events::register('badges', array($this, 'badgeContributor'));
}
public function badgeCommentator($comment = '') {
if (!empty($comment) && strlen($comment) > 5) {
return 'Achievement: Badass Commentator';
@jsolid
jsolid / actions.class.php
Last active December 11, 2015 09:59
A simple hack to setup database without password
/**
* Step #4: Database
* The validator of this form checks database connection
* and creates the database if it doesn\'t exists
* See lib/validator/dbConnectionValidator.class.php
* File location: siwapp/apps/installer/modules/static/actions/actions.class.php
*
* @param $request
*/
public function executeStep4(sfWebRequest $request)
@jsolid
jsolid / my-invoice-template.html
Last active July 25, 2017 14:05
Custom invoice template for Siwapp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="{{lang}}" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Invoice</title>
<style type="text/css">
@page { margin:0.5cm 0.5cm 0.8cm 1.5cm; }
body { margin:0.8cm auto;font:1em;}
div { display:block; }
table { border-collapse:collapse; border-spacing:0; width:99%;}
@jsolid
jsolid / _invoiceRow.php
Last active December 11, 2015 16:49
Siwapp: Show product description as well in AutoComplete drop-down, instead of showing only the ambiguous product reference code. Width is adjusted to accommodate long description string. If it's more than 40 characters, truncate it and append '...'
// File location: siwapp/apps/siwapp/modules/common/templates/_invoiceRow.php
//connect the selection of a product to update the row item
$('#".$invoiceItemForm['product_autocomplete']->renderId()."')
.autocomplete('".$urlAjaxSelectProduct."', jQuery.extend({}, {
dataType: 'json',
parse: function(data) {
var parsed = [];
for (key in data) {
parsed[parsed.length] = {
@jsolid
jsolid / Common_Twig_Extension.php
Last active December 11, 2015 16:58
Siwapp: Printing template should return a number with precision specified by the user, don't truncate zeros
// File location: siwapp/lib/templating/Common_Twig_Extension.php
function common_twig_extension_round($amount, $decimals = 2)
{
//return round($amount, $decimals);
return number_format(round($amount, $decimals), $decimals, '.', '');
}