Skip to content

Instantly share code, notes, and snippets.

View smakosh's full-sized avatar
👨‍💻
Building https://starlink-prices.com

Ismail Ghallou smakosh

👨‍💻
Building https://starlink-prices.com
View GitHub Profile
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@AshikNesin
AshikNesin / react-file-upload.js
Created February 2, 2017 06:46
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@tomysmile
tomysmile / mac-setup-redis.md
Last active May 5, 2025 13:06
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@mandiwise
mandiwise / Count lines in Git repo
Last active May 1, 2025 06:01
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@pedrosancao
pedrosancao / CharsetConversion.php
Last active March 18, 2022 14:10
Code Page 850 to UTF8 conversion, Code Page 850 to Unicode conversion, CP-850 to UTF8 conversion, CP-850 to Unicode conversion, ASCII Latin 1 to UTF8 conversion, ASCII Latin 1 to Unicode conversion
<?php
/**
* Usage: <code>CharsetConversion::CP850toUTF8('your_string');</code>
*
* @author Pedro Sanção <pedro at sancao do co>
* @license MIT Licence
*/
class CharsetConversion {
@afternoon
afternoon / rename_js_files.sh
Created February 15, 2014 18:04
Rename .js files to .ts
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
@eerohele
eerohele / swaparrayelements.js
Last active November 2, 2021 16:01
Swap two array elements (JavaScript)
/**
* Swap the elements in an array at indexes x and y.
*
* @param (a) The array.
* @param (x) The index of the first element to swap.
* @param (y) The index of the second element to swap.
* @return {Array} The input array with the elements swapped.
*/
var swapArrayElements = function (a, x, y) {
if (a.length === 1) return a;