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
@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;
@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"' {} \;
@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 {
@mandiwise
mandiwise / Count lines in Git repo
Last active July 4, 2024 16:56
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
@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;
@tomysmile
tomysmile / mac-setup-redis.md
Last active June 27, 2024 00:23
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
@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
}
@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
});
}
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active July 3, 2024 16:17
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@bradtraversy
bradtraversy / docker-help.md
Last active July 1, 2024 01:13
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info