Skip to content

Instantly share code, notes, and snippets.

View matinrco's full-sized avatar
🤔
Thinkering... 😁

Matin matinrco

🤔
Thinkering... 😁
View GitHub Profile
@matinrco
matinrco / deleteOldLogFiles.sh
Created August 30, 2017 10:00
Delete old log files in /var/log
sudo find /var/log -type f -regex ".*\.gz$" -delete
sudo find /var/log -type f -regex ".*\.[0-9]$" -delete
@matinrco
matinrco / letsencryptHowTo.sh
Last active January 25, 2018 17:06
Let’s Encrypt - issue certificates with certbot-auto and renew how to
#this file is not ready for execution
#go to /opt to download certbot-auto
cd /opt
wget https://dl.eff.org/certbot-auto
#correct permissions
chmod a+x certbot-auto
@matinrco
matinrco / toBase64.js
Last active July 14, 2023 16:11
Convert any file to base64 in javascript
var toBase64=function (file , callBack) {
file=file.files[0];
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
callBack(file,reader.result);
};
reader.onerror = function (error) {
console.log('Error: ', error);
};
@matinrco
matinrco / DragAndDrop.js
Created October 9, 2017 10:14
use jQuery drag and drop
$('div.uploadBox').on({
'drop dragdrop':function(event){
event.preventDefault();
console.log('dropped');
},
'dragenter':function(event){
event.preventDefault();
console.log('drag enter')
},
'dragleave':function(event){
@matinrco
matinrco / MongoWithRobo3t.sh
Created October 27, 2017 10:20
This script will run Robo 3T (robomongo) with MongoDB and then it will close MongoDB if you close robo 3t
#!/bin/zsh
#mongodb data directory - change this to your desired location - and check for write permissions
DIRECTORY=~/.local/share/mongodb
#create directories if not exist
mkdir -p "$DIRECTORY/data"
mkdir -p "$DIRECTORY/log"
#create empty log file if not exist
@matinrco
matinrco / preventDebouncing.js
Created October 27, 2017 19:50
Prevent click debouncing in react native
export function throttle(func, wait, ctx, immediate = true) {
let timeoutRefId;
let args;
let context;
let timestamp;
let result;
const later = () => {
const last = timestampNow() - timestamp;
@matinrco
matinrco / DisableSameOriginPolicyOnChrome.txt
Created December 3, 2017 12:21
Disable same origin policy on google chrome
Run chrome with these flags :
--disable-web-security --user-data-dir
* Windows
* In windows create google chrome shortcut somewhere & add these flags to the end of target field then relaunch it from this shortcut
* tested on chrome 62
* "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir
* Linux
* In linux it's Ez, just run it !
@matinrco
matinrco / ChainSSHByProxyCommandAndNetcat.md
Last active December 6, 2017 10:55
Chain ssh by ProxyCommand and Netcat

I have windows machine in corporate which has vpn connection to access multiple servers. But I want to acccess servers from my home computer.

So I installed openssh server from here on windows machine. Download OpenSSH-Win64.zip or OpenSSH-Win32.zip file . (version 0.0.24.0 tested)

Extract the package in C:\Program Files\OpenSSH . As the Administrator, install SSHD and ssh-agent services

powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
@media screen and (min-width: 1200px) {
}
@media screen and (min-width: 992px) and (max-width: 1199px) {
}
@media screen and (min-width: 768px) and (max-width: 991px) {
}
@media screen and (min-width: 576px) and (max-width: 767px) {
@matinrco
matinrco / MeteorRESTEndpoint.js
Created February 13, 2018 13:58
Create restful API in meteor
import Fiber from 'fibers';
import bodyParser from 'body-parser'
if (Meteor.isServer) {
WebApp.connectHandlers
.use(bodyParser.urlencoded())
.use(bodyParser.json())
.use('/getUserProfile', function(req, res, next) {