Skip to content

Instantly share code, notes, and snippets.

keep_p = 1- dropout_p
a = np.sqrt(target_var / (keep_p *((1-keep_p) * np.power(alpha-target_mean,2) + target_var)))
b = target_mear - a * (keep_p * target_mean + (1 - keep_p) * alpha)
def alpha_dropout(x, alpha_p=-1.758, dropout_p=0.05):
mask = np.random.rand(*x.shape) > dropout_p
x[mask] = alpha_p
output = a*x + b
return output
@jhass
jhass / diaspora_spam.rb
Last active February 14, 2022 09:43
Deletes spam comments, posts and local spam accounts. Place into Diasporas root, edit and run. Don't forget to set necessary environment variables.
#!/usr/bin/env ruby
# List of spam accounts
spam_accounts = %w(spamacc@podA spamacc@podB spamacc@mypod)
# Delete comments even if spammer isn't a local user or spam isn't on a
# local users account.
# And delete posts of users in spam_accounts that aren't local.
always_delete = true
@willurd
willurd / web-servers.md
Last active May 24, 2025 08:03
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@rygorous
rygorous / gist:2156668
Last active May 10, 2025 10:42
float->half variants
// float->half variants.
// by Fabian "ryg" Giesen.
//
// I hereby place this code in the public domain, as per the terms of the
// CC0 license:
//
// https://creativecommons.org/publicdomain/zero/1.0/
//
// float_to_half_full: This is basically the ISPC stdlib code, except
// I preserve the sign of NaNs (any good reason not to?)