Skip to content

Instantly share code, notes, and snippets.

View lorenzoferrante's full-sized avatar
💭
Building stuff...

Lorenzo Ferrante lorenzoferrante

💭
Building stuff...
  • Teramo, Abruzzo, Italy
View GitHub Profile
void ListeningSocketCallback(CFSocketRef sock,
CFSocketCallBackType type, CFDataRef address, const void *data,
void *info)
{
int fd = * (const int *) data;
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
NSInputStream * inputStream;
NSOutputStream * outputStream;
CFStreamCreatePairWithSocket(NULL, fd, &readStream,
// Shows latest news from MacStories in a table.
// The table shows an image from the article, if available, and the title of the article.
let numberOfArticles = URLScheme.parameter("number")
let url = "https://macstories.net/feed/json"
let shjortifyURL = "shortifyactions2:///addJSON?"
var jsonData = {"items": []}
let req = new Request(url)
let json = await req.loadJSON()
let items = json.items
@lorenzoferrante
lorenzoferrante / ViewController.swift
Created January 5, 2019 00:30
UITableView stretchy header
import UIKit
class ViewController: UITableViewController {
private let kTableViewHeaderHeight: CGFloat = 300.0
var headerView: UIView!
let clientID = '<client_id>'
let clientSecret = '<client_secret>'
let cred = clientID + ':' + clientSecret
let credEncoded = Data.fromString(cred).toBase64String()
let auth = 'Basic ' + credEncoded
// Get token
let tokenURL = 'https://accounts.spotify.com/api/token'
var reqToken = new Request(tokenURL)
reqToken.method = 'POST'
@lorenzoferrante
lorenzoferrante / Shortify.js
Created December 2, 2018 21:23
Get track or playlist URL from user query
// Base64 encoding of your credentials
let clientID = '<your client id>'
let clientSecret = '<your client secret>'
let cred = clientID + ':' + clientSecret
let credEncoded = Data.fromString(cred).toBase64String()
let auth = 'Basic ' + credEncoded
// Get token
let tokenURL = 'https://accounts.spotify.com/api/token'
var reqToken = new Request(tokenURL)
import java.io.*;
import java.util.*;
@lorenzoferrante
lorenzoferrante / 0_reuse_code.js
Created September 1, 2014 16:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lorenzoferrante
lorenzoferrante / dropUI.coffee
Last active August 29, 2015 14:04
Create Drobpox similar UI - Framer.js
iphone = new Layer(
width: 320
height: 568
backgroundColor: "#fff"
)
iphone.center()
iphone.scroll = true
header = new Layer(
width: iphone.width
height: 60
@lorenzoferrante
lorenzoferrante / responsive.coffee
Last active September 11, 2016 15:15
Responsive tool for Framer.js
# responsive.coffee
# Lorenzo Ferrante 2014
# Width variable
width60 = Screen.width / 1.66 # width: 60% -> Default
width80 = Screen.width / 1.25 # width: 80%
width90 = Screen.width / 1.11 # width: 90%
# Reload page when screen is resized
window.addEventListener "resize", (event) ->
@lorenzoferrante
lorenzoferrante / dabblet.css
Created October 13, 2013 21:22
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300);
body {
background-image: url('http://www.glasscollective.com/img/pw_maze_white.png');
}
#container {