Skip to content

Instantly share code, notes, and snippets.

View freshsnippets's full-sized avatar

Freshmade freshsnippets

View GitHub Profile
@freshsnippets
freshsnippets / Advanced Type Checking
Created March 23, 2016 20:37
Advanced type checking in sass
////
// A collection of function for advanced type checking
// @author Hugo Giraudel
// @ref https://gist.github.com/HugoGiraudel/2933ef053ae0bf70ad8b
////
@function is-number($value)
@return type-of($value) == "number"
@function is-time($value)
@freshsnippets
freshsnippets / breakpointwidth.js
Created July 22, 2013 17:24
JavaScript: In Browser Width Function to help determine Breakpoints
function breakpointWidth() {
var theWidth = $(window).width(),
theTitle = $('title');
theTitle.empty();
theTitle.html(theWidth + 'px wide ');
}
$(window).resize(function() {
breakpointWidth();
});
@freshsnippets
freshsnippets / Infinite Loop Rotating Images Using jQuery.js
Last active May 14, 2019 10:28
JavaScript: Infinite Loop Rotating Images Using jQuery
$(window).load(function() { //start after HTML, images have loaded
var InfiniteRotator =
{
init: function()
{
//initial fade-in time (in milliseconds)
var initialFadeIn = 1000;
//interval between items (in milliseconds)
@freshsnippets
freshsnippets / Display source code for pages.php
Last active October 4, 2015 05:07
PHP: Display Source Code for Pages
$lines = file('http://google.com/'); // pick the url
foreach ($lines as $line_num => $line) {
// loop thru each line and prepend line numbers
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
#
# Connect to the local database server as user root
# You will be prompted for a password.
#
mysql -h localhost -u root -p
#
# Now we see the 'mysql>' prompt and we can run
# the following to create a new database for Paul.
#
@freshsnippets
freshsnippets / Create a File.php
Created May 3, 2012 03:14
PHP: Create a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
@freshsnippets
freshsnippets / Open a File.php
Created May 3, 2012 03:14
PHP: Open a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //open file for writing ('w','r','a')...
@freshsnippets
freshsnippets / Read a File.php
Created May 3, 2012 03:14
PHP: Read a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));
@freshsnippets
freshsnippets / Write to a File.php
Created May 3, 2012 03:13
PHP: Write to a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);
@freshsnippets
freshsnippets / Append to a File.php
Created May 3, 2012 03:12
PHP: Append to a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);