Skip to content

Instantly share code, notes, and snippets.

View snobu's full-sized avatar

Adrian Calinescu snobu

View GitHub Profile
@snobu
snobu / delta.js
Created November 21, 2017 22:44
javascript time delta x days ago
async function parse() {
const feedparser = require('feedparser-promised');
const feedUrl = 'https://blogs.msdn.microsoft.com/appserviceteam/feed/';
let items = await feedparser.parse(feedUrl);
let title = items[0].title;
let date = Date.parse(items[0].pubDate);
let hoursDelta = Math.floor(date / 1000 / 60);
let daysDelta = hoursDelta % 24;
let result = `Here is the title of the most recent blog post: ${title}. ` +
@snobu
snobu / AjaxSpinner.js
Created November 29, 2017 09:37
Show spinner on ajax request (jQuery)
$.ajax({
url: "destination url",
success: ...,
error: ...,
// shows the loader element before sending.
beforeSend: function () {
$("#imgSpinner1").show();
},
// hides the loader after completion of request, whether successfull or failor.
complete: function () {
@snobu
snobu / PhantomController.cs
Last active December 21, 2017 09:21
PhantomJS in WebRole (Cloud Services)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Http;
using OpenQA.Selenium;
using OpenQA.Selenium.PhantomJS;
using OpenQA.Selenium.Support.UI;
namespace WebRole1.Controllers
@snobu
snobu / make-self-signed.sh
Created December 28, 2017 12:38
openssl generate self signed cert
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
openssl pkcs12 -inkey key.pem -in certificate.pem -export -out certificate.pfx
#dump cert info:
openssl x509 -text -noout -in certificate.pem
openssl x509 -serial -fingerprint -noout -in certificate.pem
@snobu
snobu / web-request-rust.rs
Last active March 2, 2018 00:14
web-request-rust.rs
// https://chr4.org/blog/2017/03/15/cross-compile-and-link-a-static-binary-on-macos-for-linux-with-cargo-and-rust/
//
// cargo new projectname
//
// Cargo.toml:
//
// [package]
// name = "webreq"
// version = "0.1.0"
// authors = ["snobu <foo@xxxxx.zzz>"]
@snobu
snobu / Fit Layer To Canvas.jsx
Last active March 8, 2018 13:35 — forked from jawinn/Fit Layer To Canvas.jsx
Fit Layer To Canvas - Photoshop Script
// FIT LAYER TO CANVAS
// via https://forums.adobe.com/message/5413957#5413957
var maintainAspectRatio = true; // set to true to keep aspect ratio
if (app.documents.length>0){
app.activeDocument.suspendHistory ('Fit Layer to Canvas', 'FitLayerToCanvas('+maintainAspectRatio+')');
}
function FitLayerToCanvas(keepAspect) {
@snobu
snobu / stress.ps1
Last active March 8, 2018 14:39
Stress CPU in PowerShell
$result = 1; foreach ($number in 1..[int32]::MaxValue) { $result = $result * $number }
https://stackoverflow.com/a/36158802/4148708
@snobu
snobu / sparkline-big.rs
Created March 26, 2018 21:08
tui-rs sparkline
extern crate termion;
extern crate tui;
mod util;
use util::*;
use std::io;
use std::thread;
use std::time;
use std::sync::mpsc;
@snobu
snobu / config.txt
Created March 29, 2018 09:21
Raspberry Pi 2560x1440@60Hz
hdmi_group=2
hdmi_mode=87
hdmi_cvt=2560 1440 60 3 0 0 1
max_framebuffer_width=2560
max_framebuffer_height=1440
hdmi_pixel_freq_limit=400000000