Skip to content

Instantly share code, notes, and snippets.

View nanna-dk's full-sized avatar

Nanna nanna-dk

View GitHub Profile
@nanna-dk
nanna-dk / step-by-step-arrows.html
Last active December 13, 2020 09:54
Pure CSS step navigation with dynamic height arrows
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pure CSS step navigation with dynamic height arrows</title>
<style type="text/css">
* {
box-sizing: border-box;
}
@nanna-dk
nanna-dk / gist:6155e15dcf736414f88b37e96890ac59
Created August 23, 2016 18:32 — forked from salcode/gist:6912619
jQuery function to remove all "data-" attributes from a given element
// removes all data attributes from a target element
// example: removeDataAttributes('#user-list');
function removeDataAttributes(target) {
var i,
$target = $(target),
attrName,
dataAttrsToDelete = [],
dataAttrs = $target.get(0).attributes,
dataAttrsLen = dataAttrs.length;
// An array of objects containing date ranges (dd/mm/yyyy)
var dates = [{
"id": 1,
"from": "2/12/2016",
"to": "8/12/2016",
"schedule": "Opening hours: 9-5"
}, {
"id": 2,
"from": "11/10/2017",
"to": "16/10/2017",
@nanna-dk
nanna-dk / getGitHubdata.php
Created February 22, 2018 09:41
Github API List all repositories and repo's content
<?php
// for example your user
$user = 'xxxxxxx';
// A token that you could generate from your own github
// go here https://github.com/settings/applications and create a token
// then replace the next string
$token = 'ced38b0e522a5c5e8ab10';
// Generate the url for curl
@nanna-dk
nanna-dk / getGitHubdata.html
Last active February 22, 2018 10:18
Fetch repos from GitHum using jQuery and ajax
$("#btn_get_repos").click(function() {
$.ajax({
type: "GET",
url: "https://api.github.com/users/google/repos",
dataType: "json",
success: function(result) {
for( i in result ) {
$("#repo_list").append(
"<li><a href='" + result[i].html_url + "' target='_blank'>" +
result[i].name + "</a></li>"
@nanna-dk
nanna-dk / parse-twitter-api.js
Last active May 9, 2018 08:22
Fetching tweets by Twitter api, parsing Twitter dates, hashtags, user names, etc.
<script>
$(document).ready(function() {
var $displaylimit = 20;
gettwitterjson();
function gettwitterjson() {
var $url = "twitter.php";
$.ajax({
url: $url,
type: 'GET',
@nanna-dk
nanna-dk / markers.html
Created August 3, 2018 13:12
Google Maps API multiple markes
<!DOCTYPE html>
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>
<style>
#map {
height: 400px;
@nanna-dk
nanna-dk / get-instagram-images-by-hashtag.php
Last active September 3, 2018 10:46
Instagram: Get images by hashtag - dirty solution but it works
<?php
// Function to scrape images from Instagram hashtag page. Dirty solution - may stop working at any time.
function scrape_insta_hash($tag) {
$insta_source = file_get_contents('https://www.instagram.com/explore/tags/'.$tag.'/');
$shards = explode('window._sharedData = ', $insta_source);
$insta_json = explode(';</script>', $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);
return $insta_array; // this returns a lot things print it and see what else you need
}
@nanna-dk
nanna-dk / detectImg404.js
Created October 29, 2018 13:14
Detect image 404 missing images
function ImgError(source){
source.src = "https://www.google.dk/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
source.onerror = "";
return true;
}
/* Usage:
// <img src="http://example.com/img/noImg.jpg" alt="" onerror="ImgError(this)" />
*/
@nanna-dk
nanna-dk / date-ranges.js
Created November 19, 2018 12:14
Date ranges with different text
/* An array of objects containing date ranges (dd/mm/yyyy).
* Days and months should NOT be prefixed with zero (e.g. 02/06).
* NOTE: Make sure dates are not overlapping, or the script will probably fail.
* Usage: <div id="dates"></div>
*/
var dates = [{
"id": 1,
"from": "1/11/2017",
"to": "1/1/2018",
"schedule": "<p>Message here</p>"