Tag Archive for quick

jsCookies – my simple easy pure js javascript cookies function

//  create my jsCookies function
var jsCookies = {

	// this gets a cookie and returns the cookies value, if no cookies it returns blank ""
	get: function(c_name) {
		if (document.cookie.length > 0) {
			var c_start = document.cookie.indexOf(c_name + "=");
			if (c_start != -1) {
				c_start = c_start + c_name.length + 1;
				var c_end = document.cookie.indexOf(";", c_start);
				if (c_end == -1) {
					c_end = document.cookie.length;
				}
				return unescape(document.cookie.substring(c_start, c_end));
			}
		}
		return "";
	},

	// this sets a cookie with your given ("cookie name", "cookie value", "good for x days")
	set: function(c_name, value, expiredays) {
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + expiredays);
		document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toUTCString());
	},

	// this checks to see if a cookie exists, then returns true or false
	check: function(c_name) {
		c_name = jsCookies.get(c_name);
		if (c_name != null && c_name != "") {
			return true;
		} else {
			return false;
		}
	}

};
// end my jsCookies function

// USAGE - get    ::   jsCookies.get("cookie_name_here");  [returns the value of the cookie]
// USAGE - set    ::   jsCookies.set("cookie_name", "cookie_value", 5 );  [give name, val and # of days til expiration]
// USAGE - check  ::   jsCookies.check("cookie_name_here");  [returns only true or false if the cookie exists or not]

source

QuickLook from Terminal

qlmanage -p *.jpg >& /dev/null

flags of interest include -h (displays a help message) -t (thumbnail generation) and -f (a zoom factor to display with)

source

Calculate net paycheck

function paycheck (paid, retirementPercent) {
var retireContrib = paid * retirementPercent * .01;
paid = paid - retireContrib;
var taxes = (paid * .27);
var paycheck = paid - taxes;  //taxes take 27 percent
var totalOut = retireContrib + taxes;
return retirementPercent+" 401k contribution:"+
"
Net Paycheck: ~$"+paycheck+
"
401k contrib: ~$"+retireContrib+
"
taxes paid: ~$"+taxes+
"
Total Out: ~$"+totalOut;
}
//8% retirement contribution from a $1234 paycheck:
paycheck (1234, 8);

source

Command shortform

svn st = svn status
svn ci = svn commit
svn up = svn update
svn di = svn diff
svn co = svn checkout
svn mv = svn move
svn cp = svn copy
svn rm = svn delete
svn ls = svn list
svn h  = svn help

source

PHP – InversoMoltiplicativo

<html>
<head>
<title>Calcolo degli inversi moltiplicativi</title>
</head>

<body>
<center>
<b>Cancolo dell'Inverso Moltiplicativo</b>
<br><hr><br>
<table border="1" align="center">
<?php
for($i=0; $i<26; $i++)
{
?>
<tr>
<?php
for($j=0; $j<26; $j++)
{
if($i==0) echo "<td bgcolor="yellow" align="center">" . $j . "</td>";
else
if($j==0) echo "<td bgcolor="yellow" align="center">" . $i . "</td>";
else
{
echo "<td align="center">" . $i*$j . "</td>";
$matrice[$i-1][$j-1] = $i*$j;
}
}
?>
</tr>
<?php
}

for($i=0; $i<25; $i++)
for($j=0; $j<25; $j++)
$matrice[$i][$j] = $matrice[$i][$j]%26;
?>
</table>
<br><hr>
<b>Tabella dell'Inverso Moltiplicativo</b>
<br><hr><br>
<table border="1" align="center">
<?php
for($i=0; $i<26; $i++)
{
echo "<tr>";

for($j=0; $j<26; $j++)
{
if($i==0) echo "<td bgcolor="yellow" align="center">" . $j . "</td>";
else
if($j==0) echo "<td bgcolor="yellow" align="center">" . $i . "</td>";
else
{
echo "<td align="center" " . (($matrice[$i-1][$j-1] == 1)?"bgcolor="red"":"") . "">" . $matrice[$i-1][$j-1] . "</td>";

if($matrice[$i-1][$j-1] == 1)
$np[] = $i;
}
}

echo "</tr>";
}
?>
</table>
<br>
<i><b>I numeri primi con 26 sono:
<?php
for($i=0; $i<count($np); $i++)
echo $np[$i] . " ";
?>
</b></i>
<br><br>
Si prendono le coppie di numeri che contengono il numero 1 al loro interno, esempio (1,1), (3,9)......
</center>
</body>
</html>

source