Skip to content

Instantly share code, notes, and snippets.

View akolybelnikov's full-sized avatar
:octocat:
Code weaves a story, Of logic and creativity, Developer's art form.

andrei akolybelnikov

:octocat:
Code weaves a story, Of logic and creativity, Developer's art form.
  • Shell
  • Amsterdam, Netherlands
  • 04:28 (UTC +02:00)
  • X @rokkapi
View GitHub Profile
@liangzan
liangzan / recursiveRemoveFiles.js
Created February 2, 2011 14:12
A Node.js script to remove all files in a directory recursively
var fs = require('fs')
, path = require('path')
, _ = require('underscore');
var rootPath = "/path/to/remove";
removeDirForce(rootPath);
// path should have trailing slash
function removeDirForce(dirPath) {
fs.readdir(dirPath, function(err, files) {
@scottjehl
scottjehl / getViewportSize.js
Created March 16, 2012 19:25
Reliably get viewport dimensions in JS
/*!
An experiment in getting accurate visible viewport dimensions across devices
(c) 2012 Scott Jehl.
MIT/GPLv2 Licence
*/
function viewportSize(){
var test = document.createElement( "div" );
test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;";
@cobyism
cobyism / gh-pages-deploy.md
Last active July 5, 2024 05:07
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@jczaplew
jczaplew / herok_github.md
Last active January 11, 2023 10:41
Heroku + Github + Sensitive Data

Heroku + Github + Sensitive Data

Scenario: You deployed a Heroku project that contains sensitive data (password, API key, etc) but you want to share it on Github.

Problem: You need to commit all files necessary for the application to run on Heroku. However, pushing this to Github would reveal the sensitive info.

Solution: Have a production branch (for this example, master will be the production branch) and a Github branch. The latter contains a different .gitignore that ignores the sensitive files.

@davemackintosh
davemackintosh / .htaccess
Last active May 2, 2024 15:52
Working .htaccess for Single Page Apps
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [QSA,L]
</ifModule>
@drj11
drj11 / gist:e85ca2d7503f28ebfde8
Created September 26, 2014 14:17
Copy of CVE-2014-6271.diff
Description: fix incorrect function parsing
Author: Chet Ramey <chet.ramey@case.edu>
Index: bash-4.2/bash/builtins/common.h
===================================================================
--- bash-4.2.orig/bash/builtins/common.h 2010-05-30 18:31:51.000000000 -0400
+++ bash-4.2/bash/builtins/common.h 2014-09-22 15:30:40.372413446 -0400
@@ -35,6 +35,8 @@
#define SEVAL_NOLONGJMP 0x040
@bradp
bradp / setup.sh
Last active July 6, 2024 15:14
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
@yogidevendra
yogidevendra / WeightedBiasRandomElementGenerator.java
Last active February 22, 2022 17:41
Program to generate pick elements from array random following given weighted distribution
package com.blogspot.yogidevendra.codesnippets;
import java.util.Arrays;
import java.util.Random;
/**
* To generate Random numbers based on weighted bias.
*/
public class WeightedBiasRandomElementGenerator<T>
@koistya
koistya / App.js
Last active June 8, 2022 09:55
How to add `onscroll` event in ReactJS component
import React from 'react';
let lastScrollY = 0;
let ticking = false;
class App extends React.Component {
componentDidMount() {
window.addEventListener('scroll', this.handleScroll, true);
}