Skip to content

Instantly share code, notes, and snippets.

View davidrielo's full-sized avatar
💭
I may be slow to respond.

David Rielo davidrielo

💭
I may be slow to respond.
View GitHub Profile
@davidrielo
davidrielo / wallpaper.sh
Created October 10, 2023 11:42
To change the wallpaper of mac from the shell command
# sh wallpaper.sh <path-to-the-file>
path="$1"
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'"$path"'"'
ret=$?
if [ $ret == "0" ]; then
echo "Wallpaper set successfully "
else
echo "Operation failed."
fi
@davidrielo
davidrielo / purge-node-modules.cmd
Created June 15, 2023 17:29 — forked from noseratio/purge-node-modules.cmd
Delete node_modules recursively on Windows
@echo off
set folders=node_modules
echo This will delete all [%folders%] folders recursively and cannot be undone.
choice /t 10 /d n /c yn /m "Press Y to continue, N to stop"
if %errorLevel% neq 1 goto :EOF
for /d /r . %%D in (%folders%) do if exist "%%~fD\" (echo %%D && rd "%%~fD" /s /q)

How we incorporate next and cloudfront

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

  • Every html file should never, ever be cached. Right now, our home page (just the html) is 169kb, so it's not a big deal that we're not caching html files.
@davidrielo
davidrielo / console.js
Created December 23, 2019 07:38 — forked from Harshmakadia/console.js
Mastering JS console like a Pro
// time and time end
console.time("This");
let total = 0;
for (let j = 0; j < 10000; j++) {
total += j
}
console.log("Result", total);
console.timeEnd("This");
// Memory
@davidrielo
davidrielo / client.js
Created August 30, 2018 14:09 — forked from jchillerup/client.js
remote reloading of web content with socket.io and node
var socket = io.connect('http://HOSTNAME:8080');
socket.on('reload', function (data) {
location.reload();
});
/*
socket.on('eval', function(data) {
eval(data.evalString);
});
@davidrielo
davidrielo / jsonp-cors-pub.md
Created April 18, 2018 16:37 — forked from karanth/jsonp-cors-pub.md
Notes on JSONP and CORS - cross-domain AJAX calls

There are many situations on the browser client when it would be desirable to make an AJAX call to a web-site or web service to fetch data. Many a time, the data source is on a different domain than the one from where the request is originating. These are called cross-domain requests. All browsers discourage scripts from making cross-domain requests as they are wary of the security implications in allowing arbitrary data requests across trust boundaries. At Scibler, the browser plugin that gets activated on the google mail domain needs to request data from Scibler servers to create an integrated experience for a user.

Partial mitigation of 2 important attacks is a reason why browsers advocate the Same Origin Policy (SOP) for data requests. One is called XSRF or CSRF (pronounced sea-surf) and the other XSS.

[XSRF] (http://en.wikipedia.org/wiki/Cross-site_request_forgery) stands for Cross-site Request Forgery, where in, trust on a user's browser that is providing a session with a particular site is hi

@davidrielo
davidrielo / freewheelvmap.py
Created March 21, 2018 14:17 — forked from sinkers/freewheelvmap.py
Generating a Freewheel VMAP 1.0 Ad Tag
import requests
import random
import xml.dom.minidom
'''
Simple script to simulate what needs to go in a Freewheel ad request
This example is for VMAP but what needs to be requested is similar on other response types e.g. FW Smart XML
To use Smart XML response just change the resp parameter to "xml"
'''
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@davidrielo
davidrielo / xml-to-json.es6
Created August 10, 2017 09:37 — forked from stewart/xml-to-json.es6
Given an XML Document, returns a (mostly) accurate JSON representation. WIP.
import _ from "lodash";
// flattens an object (recursively!), similarly to Array#flatten
// e.g. flatten({ a: { b: { c: "hello!" } } }); // => "hello!"
function flatten(object) {
const check = _.isPlainObject(object) && _.size(object) === 1;
return check ? flatten(_.values(object)[0]) : object;
}
export function parse(xml) {

Keybase proof

I hereby claim:

  • I am davidrielo on github.
  • I am davidrielo (https://keybase.io/davidrielo) on keybase.
  • I have a public key whose fingerprint is 52C8 4072 36C1 67BD 1288 D12A 3D1E 2E95 2376 3630

To claim this, I am signing this object: