Skip to content

Instantly share code, notes, and snippets.

View beshur's full-sized avatar

Alex Buznik beshur

View GitHub Profile
@beshur
beshur / git_notes.md
Created November 22, 2019 11:45 — forked from jaygooby/git_notes.md
Git, you bloody git

Remove all local tracking branches to a remote & then delete the remote

git remote prune origin && git remote rm origin

Force checkout a branch to avoid the commit or stash your changes warning

Sometimes when you want to checkout a branch, even though your current branch is clean, you'll get a failed partial checkout, because a file in your current branch will be changed by the new branch (Looking at you .xcodeproj files). As long as you know your current branch is clean and up-to-date, -f force the checkout

git checkout -f the_branch

@beshur
beshur / convert.sh
Created April 3, 2018 11:56 — forked from akost/convert.sh
Bash script for recursive file convertion windows-1251 --> utf-8
#!/bin/bash
# Recursive file convertion windows-1251 --> utf-8
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file
do
@beshur
beshur / пше
Created June 27, 2016 13:50 — forked from piranha/пше
пше гит, прошу пана
#!/usr/bin/env python
# -*- mode: python, coding: utf-8 -*-
#
# This incredible piece of code makes git a bit Polish, a bit Western Ukrainian,
# пше прошу пана
# Joke is based on fact that 'git' is 'пше' in qwerty/йцукен layouts
#
# (c) 2013 Alexander Solovyov under terms of WTFPL
import sys
@beshur
beshur / pr.md
Created March 18, 2016 11:38 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@beshur
beshur / lol.js
Created February 17, 2016 12:17 — forked from wesbos/lol.js
// paste in your console
speechSynthesis.onvoiceschanged = function() {
var msg = new SpeechSynthesisUtterance();
msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0];
msg.text = Object.keys(window).join(' ');
this.speak(msg);
};
@beshur
beshur / README.md
Last active December 1, 2015 15:40 — forked from mbostock/.block
Force-Directed Graph

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

Compare this display to a force layout with curved links, a force layout with fisheye distortion and a matrix diagram.

@beshur
beshur / gm-fsdfm.php
Last active August 29, 2015 14:24 — forked from gmazzap/gm-fsdfm.php
<?php namespace GM\FSDFM;
/**
* Plugin Name: Fullscreen Distraction-Free Mode (pre v4.1)
* Description: Allows to use the distraction-free mode that was active pre 4.1 WP version.
* Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/c081ce03a68b00d983d5
* Author: Giuseppe Mazzapica
* Author URI: https://gm.zoomlab.it
* License: MIT
* Version: 1.0.0
*/
@beshur
beshur / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// Go to menue:
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// Where:
c:\your_folder\,*.php,*.phtml,*.js,*.inc,*.html, -*/folder_to_exclude/*
// Then click on the find button
// Be careful to not click on Replace!!!
@beshur
beshur / route.js
Last active August 21, 2019 04:02 — forked from cultofmetatron/gist:5349630
Javascript Node.js Express Login route with ajax responses
app.post('/login', function(req, res) {
console.log(res);
passport.authenticate('local', function(err, user, params) {
if (req.xhr) {
//thanks @jkevinburton
if (err) { return res.json({ error: err.message }); }
// e.g. in auth.js:
// if (!user.emailVerified) { return done(null, false, { message: 'Email is not verified. Please check your email for the link.' }); }
if (!user && params) { return res.json({error : params.error}); }