Skip to content

Instantly share code, notes, and snippets.

View TahaBoulehmi's full-sized avatar
🎯
Focusing

Taha Boulehmi TahaBoulehmi

🎯
Focusing
View GitHub Profile
@TahaBoulehmi
TahaBoulehmi / heroku.env.js
Created September 16, 2022 10:01
Export Heroku env
// This script lets you export all heroku config vars
// 1) Go to your app settings and reveal config vars
// 2) Open the console and run this code:
// BONUS: You can add this script as a bookmark.
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
function print(str) {
document.getElementById('resultzone').innerHTML += `<br><b>${JSON.stringify(str)}</b>`;
}
const seperateNumbers = function(arr) {
const evenNumbers = [];
const oddNumbers = [];
for (let i = 0; i < arr.length; i++) {
(arr[i] % 2 === 0) ? evenNumbers.push(arr[i]) : oddNumbers.push(arr[i]);
@TahaBoulehmi
TahaBoulehmi / screenshot.js
Last active October 18, 2019 17:42
This is a fix for Nightmare JS to allow making screenshots when the website forces a JavaScript redirection
var n = Nightmare({
switches: { 'ignore-certificate-errors': true, 'force-device-scale-factor': options.scale ? options.scale.toString() : '1' },
show: typeof options.show === 'boolean' ? options.show : true,
width: options.width || 1280,
height: options.height || 720
});
n
.viewport(options.width || 1280, options.height || 720)
@TahaBoulehmi
TahaBoulehmi / using-raw-socket-io-in-sails.js
Last active June 20, 2019 13:16
Using Raw Socket IO In Sails.js
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
@TahaBoulehmi
TahaBoulehmi / UserController.js
Last active April 2, 2018 16:17
Facebook Authentication using Sails.js
facebookAuth: function(req, res) {
//You need to add the fb signup button in the frontend, and post the token that you got from facebook to the backend.
if (_.isUndefined(req.param('facebookToken'))) {
return res.json({
success: false,
msg: 'Please log in using your facebook account'
});
}
// Get information about the Facebook user with the specified access token.