Skip to content

Instantly share code, notes, and snippets.

@ahallora
ahallora / getSpotifyAccessToken
Last active March 17, 2023 09:44
Get Spotify Access Token (client credentials) with PHP and cURL
<?php
$client_id = '<insert your spotify app client id>';
$client_secret = '<insert your spotify app client secret>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://accounts.spotify.com/api/token' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials' );
@ahallora
ahallora / server.js
Last active November 18, 2015 09:43
Spotify Token Exchange (written in node.js)
// Node.js version of the Spotify Token Exchange originally scripted in ruby (based on beta 6 release candidate)
// https://github.com/spotify/ios-sdk/blob/master/Demo%20Projects/spotify_token_swap.rb
var express = require('express');
var bodyParser = require('body-parser');
var request = require('request');
var app = express();
var http = require('http').Server(app);
var config = {}
@ahallora
ahallora / keybase.md
Created March 4, 2015 05:41
keybase.md

Keybase proof

I hereby claim:

  • I am ahallora on github.
  • I am aholm (https://keybase.io/aholm) on keybase.
  • I have a public key whose fingerprint is F66A D56D 665E 27CA 607B D762 FECA 5321 AC4F C509

To claim this, I am signing this object:

@ahallora
ahallora / executesql.js
Last active August 29, 2015 14:17
PDO with MS-SQL (Azure) and Node.js
// -------------------------------------------------------------------------
// USING MSSQL NPM AND PREPARED STATEMENTS IN NODE.JS
// ENABLING ? AS PLACEHOLDERS IN SQL AND AUTOMATIC TYPECASTING OF PARAMETERS
// THIS IS WORKING ON AZURE WITH NODE.JS AND MSSQL NODE MODULE - YAII :)
// -------------------------------------------------------------------------
// MIT LICENSE 2015 @ Anders Holm-Jensen
// -------------------------------------------------------------------------
var sql = require('mssql');
var config = {
@ahallora
ahallora / script.js
Last active July 3, 2022 05:00
Validate Spotify Playlist HTTP and URI
/*
* Script to validate Spotify playlist HTTP and URI's
* Valid format: http://open.spotify.com/user/__username__/playlist/__playlistID__
* spotify:user:__username__:playlist:__playlistID__
*
* License: MIT
*/
function validateSpotifyPlaylistHTTPandURI(input) {
isValid = false;
@ahallora
ahallora / Click Rate Limiter.html
Created February 16, 2016 10:19
A simple Click Rate Limiter / Debouncer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<ul id="list"></ul>
<button id="thebutton">Try me</button>
@ahallora
ahallora / readme.rmd
Created March 30, 2016 13:12
How to make SSL work on Microsoft Azure
##How to make SSL work on Microsoft Azure
##### Microsoft Azure requires a password-protected PFX file (containing the public key for your domain including any and all intermediate CA certs) in order to support HTTPS (TLS - SSL) support on your Azure hosted websites. Here's how to get it working with certificates from GeoTrust / RapidSSL (and others too probably).
__1) Create CSR__
Create a CSR-file and private key with OpenSSL and upload it to your CA:
```
openssl req -new -nodes -keyout yourprivatekey.key -out server.csr -newkey rsa:2048
```
@ahallora
ahallora / animation.html
Created October 30, 2016 19:59
PNG Sprite Animation with CSS
<style type="text/css">
.pngAnimation {
background: url(../assets/img/ourdio-sprite-png.png) no-repeat left top;
background-size: 2900%; /* 28+1 steps * 100% */
height: 50px;
width: 50px;
animation: o-burst 1000ms steps(28) infinite;
}
@ahallora
ahallora / test.html
Created November 4, 2016 12:24
Ractive test: Change object across "ractives"
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ractive/0.8.4/ractive.min.js" integrity="sha256-heXunjNkqBw9mc4urNeQE1t8qZRu4c8jSqjhE7c45BU=" crossorigin="anonymous"></script>
<h1>Ractive test</h1>
<div style="float: left; width: 50%; background-color: #eee;" id="placeholderOne"></div>
<div style="float: left; width: 50%; background-color: #ddd;" id="placeholderTwo"></div>
@ahallora
ahallora / input masking.html
Last active November 7, 2016 11:20
Input Masking
<!--
Author: Anders Holm-Jensen @ 7-NOV-2016
License: MIT
-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.slim.js" integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA=" crossorigin="anonymous"></script>
<h4>Input Masking</h4>
<input type="text" class="datamasked-input" data-maskgroup="partygroup" data-masklength="6" value="" onclick="alert('yes, we made it! Now join ' + this.value);" />
<script type="text/javascript">