Skip to content

Instantly share code, notes, and snippets.

View jimmy89Li's full-sized avatar

Li jimmy89Li

View GitHub Profile
@jimmy89Li
jimmy89Li / index.html
Created March 3, 2017 10:59
css new style for radio buttons
<label for="accessible">
<input type="radio" value="accessible" name="quality" id="accessible"> <span>accessible</span>
</label>
<label for="pretty">
<input type="radio" value="pretty" name="quality" id="pretty"> <span>pretty</span>
</label>
<label for="accessible-and-pretty">
<input type="radio" value="pretty" name="quality" id="accessible-and-pretty" checked> <span>accessible and pretty</span>
@jimmy89Li
jimmy89Li / redirect.html
Created February 23, 2017 13:20
Redirect website to another domain
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.location="http://liviusimion.com";
</script>
</head>
<body>
@jimmy89Li
jimmy89Li / insert.php
Last active February 23, 2017 13:18
Insert sql into multiple tables in the same time
$sql = "BEGIN TRANSACTION;";
$sql .= "INSERT INTO table1 (name1) VALUES (value1);";
$sql .= "INSERT INTO table2 (name2) VALUES (value2);";
$sql .= "COMMIT;";
@jimmy89Li
jimmy89Li / functions.php
Created September 28, 2016 07:23
Allow the editor to edit theme options
// Allow the editor to edit theme options
function add_theme_caps() {
// gets the editor role
$role = get_role( 'editor' );
// This only works, because it accesses the class instance.
// would allow the editor to edit options posts for current theme only
$role->add_cap( 'manage_options' );
}
add_action( 'admin_init', 'add_theme_caps');
@jimmy89Li
jimmy89Li / divAsButton.html
Created September 20, 2016 09:01
Div as checked input button
<div id="Type1" class="packages" >
<p>Type 1</p>
<div class="optionsContainer">
<input type="radio" name="type1" id="package11">
<label class="radio-inline package-options" for="package11">Package #1.1</label>
<input type="radio" name="type1" id="package12">
<label class="radio-inline package-options" for="package12">Package #1.2</label>
<input type="radio" name="type1" id="package13">
<label class="radio-inline package-options" for="package13">Package #1.3</label>
</div>
@jimmy89Li
jimmy89Li / index.html
Created September 20, 2016 09:00
Show divs based on selected options value
<Select id="packageOption">
<option value="">None</option>
<option value="package1">Package1</option>
<option value="package2">Package2</option>
<option value="package3">Package3</option>
</Select>
<div id="package1" class="packages" > Package1 </div>
<div id="package2" class="packages" > Package2 </div>
<div id="package3" class="packages" > Package3 </div>
@jimmy89Li
jimmy89Li / refresh.js
Created September 7, 2016 09:51
Refresh function on load and every 10 min
refreshWeather();
setInterval(refreshWeather, 600000); // Recall every 10 min
@jimmy89Li
jimmy89Li / strtotime.js
Created September 6, 2016 09:55
strtotime JS replacement
var dateString = Date.parse("2016-08-01T12:00:00+0000");
var fbSince = dateString / 1000;
document.write(fbSince);
@jimmy89Li
jimmy89Li / weatherIcon.js
Created August 31, 2016 08:50
Set weather icon based on the forecast, using "meteocons" font type (http://www.alessioatzeni.com/meteocons/)
$.getJSON('http://api.wunderground.com/api/API_KEY/conditions/q/CITY_NAME.json', function(Weather) {
var weatherInfo = Weather.current_observation;
var weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="1">';
if(weatherInfo.weather === 'Partly Cloudy') {
weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="3">';
}
else if (weatherInfo.weather === 'Mostly Cloudy') {
weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="5">';
}
else if (weatherInfo.weather === 'Rain') {
@jimmy89Li
jimmy89Li / weatherTempC.js
Last active August 31, 2016 09:23
Get the Celsius degrees for a specific city
$.getJSON('http://api.wunderground.com/api/API_KEY/conditions/q/CITY_NAME.json', function(Weather) {
var weatherInfo = Weather.current_observation;
console.log(weatherInfo.temp_c);
document.getElementById('weatherTempC').innerHTML = weatherInfo.temp_c;
});