Skip to content

Instantly share code, notes, and snippets.

@saqibameen
saqibameen / limit-words.css
Created July 27, 2020 14:10
Limit no of characters inside your element
/*
* Limits the no of character in your element.
*/
.trim-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 75ch;
}
@saqibameen
saqibameen / async-await-error-handling.js
Created July 26, 2020 19:26
Code snippet to gracefully handle errors with async await
// HOC to handle error.
function handleError(fn){
return function(...params) {
return fn(...params).catch(function (err) {
console.error(`Oops! ${err}`);
});
}
}
// Our async function
// Response from Hosted Domains API by IPInfo.io
{
"domain": "comcast.net",
"ip": "69.252.80.75",
"asn": "AS7922",
"count": 939,
"range": "69.240.0.0/12",
"domains": [
[
"comcast.net",
// Response from Range API agains comcast.net.
{
"domain": "comcast.net",
"num_ranges": "37330",
"ranges": [
"23.24.240.0/29",
"23.24.240.64/29",
"23.24.240.128/28",
"23.24.240.152/29",
"23.24.240.168/29",
{
"domain": "comcast.net",
"num_ranges": "37330",
"ranges": [
"23.24.240.0/29",
"23.24.240.64/29",
"23.24.240.128/28",
"23.24.240.152/29",
"23.24.240.168/29",
"23.24.240.192/29",
// The response from the ASN API.
{
"asn": "AS7922",
"name": "Comcast Cable Communications, LLC",
"country": "US",
"allocated": "1997-02-14",
"registry": "arin",
"domain": "comcast.net",
"num_ips": 71220480,
"prefixes": [
# Hitting /batch endpoint with mulitple IP addresses.
curl -XPOST -H "Content-Type: application/json" \
--data '["75.72.7.215/company", "8.8.4.4/asn"]' \
ipinfo.io/batch?token=$TOKEN # TOKEN contains your ipinfo token
# Response in JSON.
{
"75.72.7.215/company": {
"name": "Comcast Cable Communications, LLC",
@saqibameen
saqibameen / go-settings.sh
Created March 20, 2019 22:47
Setting Paths for GO
export GOPATH=/Users/saqibameen/Code/sa-learn-go/project1/main
export GOBIN=$GOPATH/bin
PATH=$PATH:$GOPATH:$GOBIN
export PATH
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@saqibameen
saqibameen / css-starter.css
Created February 28, 2019 15:35
css starter file
/**
* Main CSS
*
* @author Saqib Ameen
*/
/* global box-sizing */
*,
*:after,
*:before {