Skip to content

Instantly share code, notes, and snippets.

View LayneSmith's full-sized avatar
🎯
Focusing

Layne Smith LayneSmith

🎯
Focusing
View GitHub Profile
//CHECK DUPLICATE IPs
$ip = $_SERVER["REMOTE_ADDR"];
$maxDuplicates = 200;
$sql = "SELECT COUNT(*) FROM --currentTable-- WHERE ip = '$ip'";
$res = $db->query($sql);
$duplicateIP = $res->fetchColumn();
n = name
s = symbol
l1 = last trade
c1 = change
g = day low
h = day high
j = 52 week low
k = 52 week high
p2 = %change
a2 = average daily volume
@LayneSmith
LayneSmith / Facebook Sharing.js
Last active August 29, 2015 14:18
Changing sharing data
//REASSIGN VARIABLES
storyTitle = "New title, can also be a variable with no quotes.";
storyURL = "http://res.dallasnews.com/graphics/2015_03/index.html"; //Can also be a variable
storyImG = "http://res.dallasnews.com/graphics/2015_03/customPreview.jpg"; //Can also be a variable
leadText = "A custom description based on whatever you can script", //Can also be a variable
//ATTACH THEM TO THE APPROPRIATE PROPERTIES
$("meta[property='og\\:title']").attr("content", storyTitle);
$("meta[property='og\\:url']").attr("content", storyURL);
$("meta[property='og\\:image']").attr("content", storyImg);
//url formate should be ...index.html/?targetDiv
$(document).ready(function () {
//CHECK FOR VARIABLES IN URL
var rawKeys = $(location).attr('search');
if (rawKeys) {
console.log(rawKeys); //displays "?targetDiv"
var strippedKey = rawKeys.substring(1); //get rid of question mark
console.log(strippedKey); //displays "targetDiv"
//JQUERY
//THIS WILL NEED TO SET COOKIE AFTER VOTE
if ($.cookie(thisPage) != "true"){
$.cookie(thisPage, true, { expires: 60 });
alert("Welcome!");
} else {
alert("You've already been here!");
}
//JAVASCRIPT SET THE NEW COOKIE
function is_touch_device() {
return 'ontouchstart' in window || 'onmsgesturechange' in window;
};
var isMobile = is_touch_device();
if (isMobile){
}else{
@LayneSmith
LayneSmith / check.php
Created June 18, 2015 13:39
Check SQL in PHP
$sql = "SELECT COUNT(*) FROM " . $thisTable . " WHERE ip = '$ip'";
echo $sql;
$res = $db->query($sql);
if (! $res) {
print_r($db->errorInfo());
}
$duplicateIP = $res->fetchColumn();
///Branching an existing branch
git pull origin <original branch name>
git checkout <original branch name>
git checkout -b <new branch name>
# Edit some files
git add .
git commit -m “Added some stuff”
git push origin <new branch name>
git checkout <branch name>
git add .
git commit -m "enter a commit message"
git checkout master
git merge <branch name>
git add .
git commit -m "merged"
git push origin master
//Create a new repository
git init
//Start copy from github
git clone https://github.com/LayneSmith/shotput.git
//Fetch and merge changes on remote server to your working directory
git pull
//List all remote and local branches