This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unique_ids3(itr) | |
# create individual dictionaries for each thread, | |
# where keys have the type of itr's elements | |
d = [Dict{eltype(itr), Vector{Int}}() for _ in 1:Threads.nthreads()] | |
# iterate through itr, using automatic threading | |
# :static ensures that threadid() remains constant within an iteration | |
Threads.@threads :static for index in eachindex(itr) | |
id = Threads.threadid() | |
@inbounds val = itr[index] | |
# check if the dictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
function bubble_sort(v::AbstractArray{T}) where T<:Real | |
for _ in 1:length(v)-1 | |
for i in 1:length(v)-1 | |
@inbounds if v[i] > v[i+1] | |
v[i], v[i+1] = v[i+1], v[i] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder