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 / 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
@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 / 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) {
@matinrco
matinrco / npm-global-without-sudo.md
Last active March 9, 2018 17:25
Install npm packages globally without sudo on macOS or Linux

Install npm packages globally without sudo on macOS or Linux

1. Create a directory for global packages
mkdir "${HOME}/.npm-packages"
2. Indicate to npm where to store globally installed packages. In your ~/.npmrc file add:
@matinrco
matinrco / VMWare3DEnabler.md
Created March 10, 2018 14:28
Enable 3D HW acceleration on VMWare Workstation on Linux host

Enable 3D HW acceleration on VMWare Workstation on Linux host


Add mks.gl.allowBlacklistedDrivers = "TRUE" to ~/.vmware/preferences

That's it :)