Skip to content

Instantly share code, notes, and snippets.

View braska's full-sized avatar

Danil Agafonov braska

  • Diligent Corporation
  • Vancouver, Canada
  • 15:44 (UTC -08:00)
View GitHub Profile
/**
* Automatically applies "p" and "br" markup to text.
* Basically [nl2br](http://php.net/nl2br) on steroids.
*
* echo Text::auto_p($text);
*
* [!!] This method is not foolproof since it uses regex to parse HTML.
*
* @param string $str subject
* @param boolean $br convert single linebreaks to <br />
@braska
braska / index.html
Last active January 15, 2016 19:21
Canvas Lukeboard
<html>
<head>
<meta charset="utf-8"/>
<title>HTML5 Canvas Drawing Board</title>
<script type="text/JavaScript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
@braska
braska / build.gradle
Created February 17, 2016 19:46
Spring example gradle config
buildscript {
ext {
springBootVersion = '1.4.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
@braska
braska / DialogLayout.jsx
Last active August 14, 2016 23:09
Unexpected Remount React Component
import React from 'react';
import {Loader} from 'react-loaders';
import {Button} from 'react-bootstrap';
import DialogTopBar from '../components/DialogTopBar';
import DialogInputBarContainer from '../containers/DialogInputBarContainer';
import DialogMessagesLayoutContainer from '../containers/DialogMessagesLayoutContainer';
export default class DialogLayout extends React.Component {
static propTypes = {
currentDialog: React.PropTypes.object.isRequired,
@braska
braska / vk-music-downloader.js
Last active January 11, 2024 20:14
Download first 50 audios from current playlist from VK.com one by one
/*
1. Open Audios
2. Copy this script
3. Insert to developer console and run
4. Enjoy!
*/
//download.js v4.2, by dandavis; 2008-2016. [CCBY2] see http://danml.com/download.html for tests/usage
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
@braska
braska / output
Created January 10, 2017 12:03
fedora workstation lsmod output
Module Size Used by
hid_logitech_hidpp 28672 0
hid_logitech_dj 20480 0
xt_nat 16384 83
cmac 16384 0
veth 16384 0
xfs 1024000 17
xt_addrtype 16384 2
br_netfilter 24576 0
rfcomm 77824 2
@braska
braska / patch.js
Last active March 24, 2017 13:52
Redux Dispatch Monkey Patching
/**
How to use:
1. Inside React Dev Tools select <Provider>
2. Copy this script
3. Paste to console
4. Run
*/
let store = $r.store;
let rawDispatch = store.dispatch;
@braska
braska / index.pug
Last active September 25, 2022 16:55
Express React SSR
doctype html
<html !{helmet.htmlAttributes.toString()}>
head.
!{helmet.title.toString()}
!{helmet.meta.toString()}
!{helmet.link.toString()}
<body !{helmet.bodyAttributes.toString()}>
#root.
!{content}
script(src=assets['manifest.js'])
@braska
braska / huffman.go
Created November 13, 2017 00:28
Huffman text encoder/decoder
package main
import (
"flag"
"fmt"
"os"
"bufio"
"math"
"bytes"
"encoding/gob"
const NODE_ENV = process.env.NODE_ENV || 'development';
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const path = require('path');
const addHash = (template, hash) =>
NODE_ENV === 'production' ? template.replace(/\.[^.]+(\.map)?$/, `.[${hash}]$&`) : template;