Skip to content

Instantly share code, notes, and snippets.

View basiclines's full-sized avatar

Ismael Canal basiclines

View GitHub Profile
@basiclines
basiclines / figma_hooks_slack.js
Created January 11, 2021 16:59
AWS lambda for sending Slack messages from Figma Hooks API
const https = require('https');
const querystring = require('querystring');
/**
* Pass the data to send as `event.data`, and the request options as
* `event.options`. For more information see the HTTPS module documentation
* at https://nodejs.org/api/https.html.
*
* Will succeed with the response body.
*/
@basiclines
basiclines / GoogleOAuth.js
Created May 17, 2020 10:15
Server side implementation for Google OAuth2
const crypto = require('crypto')
const url = require('url')
const fs = require('fs')
const http = require('http')
const express = require('express')
const {google} = require('googleapis')
const successView = require('./success_view')
const errorView = require('./error_view')
const googleCredentials = require('./google_client_id.json')
@basiclines
basiclines / defaultbrowser.sh
Last active March 27, 2020 08:23
Sets the current browser as default each 1s
#!bin/bash
while true; do
firefox=$(ps aux | grep -v grep | grep -ci "firefox")
safari=$(ps aux | grep -v grep | grep -ci "safari")
opera=$(ps aux | grep -v grep | grep -ci "opera")
brave=$(ps aux | grep -v grep | grep -ci "brave")
chrome=$(ps aux | grep -v grep | grep -ci "chrome")
if [ $firefox -gt 0 ]
then
/**
* Custom breakpoints
*
*/
@custom-media --desktop-XL screen and (max-width: 1920px);
@custom-media --desktop-L screen and (max-width: 1440px);
@custom-media --desktop-M screen and (max-width: 1280px);
@custom-media --desktop-S screen and (max-width: 1080px);
@custom-media --desktop-XS screen and (max-width: 900px);
@basiclines
basiclines / download_images.js
Created October 17, 2017 07:32
NodeJS script to download a batch of images one by one
var fs = require('fs'),
request = require('request');
images = require('./images') // Array of images urls
var download = function(uri, filename, callback){
request.head(uri, function(err, res, body){
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
});
};
@basiclines
basiclines / remove_git_submodules
Created October 11, 2017 13:19
Safely remove git submodules
#!/bin/bash
mv location/module_name location/module_name_2
git submodule deinit -f -- location/module_name
git rm -f location/module_name
rm -rf location/module_name_2
@basiclines
basiclines / git_move_batch
Created September 1, 2016 10:17
Performs a git move command in a batch of files by renaming file extension
#!/bin/bash
for file in source/*.html.twig; do
git mv "$file" "`basename "$file" .html.twig`.tpl.html"
done
@basiclines
basiclines / raspberry_installer.sh
Last active April 6, 2016 15:12
Raspberry distros installer script
#!/bin/bash
diskutil list
# Grab your disk location, i'm using /disk2
diskutil unmountDisk /dev/disk2
sudo dd if=/dev/zero of=/dev/rdisk2 bs=1024
sudo dd if=OpenELEC-RPi2.arm-6.0.3.img of=/dev/rdisk2 bs=4m
sync
diskutil unmountDisk /dev/disk2
@basiclines
basiclines / mergeMyImages.sh
Created January 23, 2013 17:27
Used for automatically choose remote images files for resolving conflicts in Git and keeps logs of all that images changes
# Script used for automatically choose remote images files for resolving conflicts in Git
# You need your working copy to be in merging status
# Define main folders
LOG_FOLDER="git_log/"
STATUS_FILE=$LOG_FOLDER"raw_status.txt";
BOTH_FILE=$LOG_FOLDER"both_modified.txt";
THEIRS_FILE=$LOG_FOLDER"theirs_modified.txt";
THEIRS_NEWFILE=$LOG_FOLDER"theirs_new.txt";
THEIRS_DELETIONSFILE=$LOG_FOLDER"theirs_deleted.txt";
@basiclines
basiclines / rest.js
Last active December 10, 2015 17:18
NodeJs API server that returns the content of the url
// CURL
var util = require('util');
var exec = require('child_process').exec;
// API RESPONSE
var http = require('http');
var sys = require('sys');
var server = http.createServer(function(req, res) {
res.writeHead(200, {