Skip to content

Instantly share code, notes, and snippets.

View digital-carver's full-sized avatar

SundaraRaman R digital-carver

View GitHub Profile
@digital-carver
digital-carver / AfraidOfEven.cpp
Created October 21, 2010 13:19
Assume an arithmetic progression (AP) is taken and each member is divided by powers of 2 until it becomes odd. Take such a sequence as input, and find the original arithmetic progression. (Max. 50 elements in input sequence, error checking knowingly left
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX_32_SIGNED = 2147483647;
class AfraidOfEven
{
@digital-carver
digital-carver / CPANSyntaxHighlight.user.js
Last active March 5, 2019 08:03
A Greasemonkey script to enable syntax highlighting when viewing module sources on CPAN
// ==UserScript==
// @name CPANSyntaxHighlight
// @namespace abiteasier.in
// @description Enable syntax highlighting when viewing the source on CPAN
// @include http://cpansearch.perl.org/src/*
// @version 0.9
// @require http://yandex.st/highlightjs/7.3/highlight.min.js
// @resource syntaxHighlightCSS http://yandex.st/highlightjs/7.3/styles/github.min.css
// @grant GM_addStyle
// @grant GM_getResourceText
@digital-carver
digital-carver / tabular_after.vim
Last active August 27, 2015 12:32
An `after/plugin` function for Tabular.vim to allow PCRE (using eregex.vim)
if exists(':E2v')
function! AlignByRE() range
let range = a:firstline . ',' . a:lastline
let cmd = range
let re = input('Enter PCRE to align by: ')
if re == ""
" Run empty to use previous pattern
let cmd .= 'Tabularize'
execute cmd
else
@digital-carver
digital-carver / cyg_removable_deps.sh
Created March 2, 2018 10:34
List unneeded dependencies from Cygwin
#!/bin/bash
# Print a list of packages that no other package depends on
# Script taken from https://superuser.com/a/570575/3200
PackageCount=0
PackageIter=0
# Populate package array
declare -A Packages
PackageList=$(cygcheck.exe -c | cut -d' ' -f1 | tail -n +3)
@digital-carver
digital-carver / gcc_predef_macros_cygwin.c
Created May 3, 2018 08:31
Output of `gcc -dM -E - <<<''` on Cygwin 2.10.0 x86_64 with gcc 6.4.0
#define __DBL_MIN_EXP__ (-1021)
#define __UINT_LEAST16_MAX__ 0xffff
#define __ATOMIC_ACQUIRE 2
#define __FLT_MIN__ 1.17549435082228750797e-38F
#define __GCC_IEC_559_COMPLEX 2
#define __UINT_LEAST8_TYPE__ unsigned char
#define __SIZEOF_FLOAT80__ 16
#define __INTMAX_C(c) c ## L
#define __CHAR_BIT__ 8
#define __UINT8_MAX__ 0xff
import random
# import matplotlib.pyplot as plt
suits = ['hearts', 'diamonds', 'spades', 'clubs']
value = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
cards = []
for item in suits:
for number in value:
cards.append([number, item])
@digital-carver
digital-carver / YourbanPro.user.js
Last active November 16, 2020 21:44
Userscript for use with UrbanPro website
// ==UserScript==
// @name YourbanPro
// @namespace aaressaar
// @match http*://www.urbanpro.com/*
// @grant none
// @version 0.5
// @author SundaraRaman
// @description Remove annoyances and improve UrbanPro interface
// ==/UserScript==
" Easy insertion of emojis with C-K
execute 'digraph :x 128544'
execute 'digraph :) 128578'
execute 'digraph :D 128512'
execute 'digraph =D 128513'
execute 'digraph :P 128523'
execute 'digraph :\| 128528'
execute 'digraph =\| 128529'
execute 'digraph :O 128558'
execute 'digraph :/ 128533'
@digital-carver
digital-carver / showsource.jl
Created November 28, 2021 23:29
Quick and dirty macro/function to show some source code of a function
macro showsource(ex0...)
InteractiveUtils.gen_call_with_extracted_types_and_kwargs(__module__, :showsource, ex0)
end
showsource(f, @nospecialize t; kwargs...) = showsource(functionloc(f,t)...; kwargs...)
function showsource(file::AbstractString, line::Integer; nlines = 10)
run(pipeline(`tail -n +$(line) $file`, `head -n $(nlines)`))
nothing
end
@digital-carver
digital-carver / TablesDocsPartial-discountoutput.html
Last active April 11, 2022 14:43
Discount markdown parser testing
<h3><code>Tables.columns</code> usage</h3>
<p><pre><code class=", now let's take a look at a case utlizing [`Tables.columns`](@ref).">
The following code is taken from the [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl/blob/master/src/other/tables.jl)
Tables.jl implementation:
</code></pre>
getvector(x::AbstractVector) = x
getvector(x) = collect(x)</p>
<h1>note that copycols is ignored in this definition (Tables.CopiedColumns implies copies have already been made)</h1>