Skip to content

Instantly share code, notes, and snippets.

View lukasz-madon's full-sized avatar

Lukasz lukasz-madon

View GitHub Profile
(function() {
window.S3Upload = (function() {
S3Upload.prototype.s3_object_name = 'default_name';
S3Upload.prototype.s3_sign_put_url = '/signS3put';
S3Upload.prototype.file_dom_selector = 'file_upload';
# given list [2, 3, 5, 78]
# return 1, 4, 6-77, 79-99
# the range is always <1, 100)
def get_ranges(lst, N=100):
s = set(lst)
filtered = (i for i in xrange(1, N) if not i in s)
output2 = []
prev = None
skipping = False
for num in filtered:
I wanna write a small tool that will swap music from my youtube video. Currently it's binary
if override_audio:
o_cmd = ["ffmpeg", "-i", music_url, "-i", video_url, "-codec", "copy",
"-y", "-shortest", output_video]
logger.info(o_cmd)
code = sp.call(o_cmd)
else:
cmd = ["ffmpeg", "-i", music_url, "-i", video_url, "-filter_complex",
"amix=duration=shortest", "-vcodec", "copy", "-y", "-shortest",
output_video]
using System;
using System.Linq;
namespace EnumTest
{
public enum ContentAreaTagEnum
{
Unknown,
[ContentArea(Name = "Full")]
"use latest";
let MongoClient = require('mongodb').MongoClient;
const questions = `
<html>
<head>
<title>Euler problems</title>
</head>
<body>
# -*- coding: utf-8 -*-
"""Convert Unicode text into plain ASCII string."""
# for brevity the table is kept simple
CONVERSION_TABLE = {
u"\u0394": "D",
u"\u03b1": "a",
u"\u03bd": "n",
u"\u03ac": "a",
u"\u03b7": "e"
@lukasz-madon
lukasz-madon / gist:53a4a89a738ffb7c85e7
Created November 16, 2015 13:49
Generate CSRF token
/// <summary>
/// Generates AntiForgery Tokens
/// </summary>
public static class AntiForgeryTokensGenerator
{
private const string ConstantSalt = "b8YagDpYwB";
private static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider();
// buffer for random string with 32 bytes of entropy
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {
@lukasz-madon
lukasz-madon / gist:6685451
Created September 24, 2013 14:17
Reversing bits in python e.g 13 which is 1101 becomes 1011 which is 11
def reverse_bits(x):
out = 0
len = 0
num = x
while num > 0:
num /= 2
len += 1
for i in xrange(0, len):
bit = x >> i & 1
out |= bit << (len - 1 - i)
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",