Skip to content

Instantly share code, notes, and snippets.

Nil-Zil

Block or report user

Report or block Nil-Zil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Nil-Zil
Nil-Zil / plotlyresize.js
Created May 29, 2017
Adjust Plotly's plot size responsively according to window motion
View plotlyresize.js
// Some info about viewport percentages:
// http://stackoverflow.com/questions/1575141/make-div-100-height-of-browser-window
// Code from https://codepen.io/plotly/pres/wKpPvj
(function() {
var d3 = Plotly.d3;
var WIDTH_IN_PERCENT_OF_PARENT = 60,
HEIGHT_IN_PERCENT_OF_PARENT = 80;
View create_folder.py
import os
my_path = os.path.abspath(__file__ + "/../../")
if not os.path.exists(my_path + "/folder"):
os.makedirs(my_path + "/folder")
View loading-MathJax-Dynamically.js
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML";
var config = 'MathJax.Hub.Startup.onload();';
if (window.opera) {script.innerHTML = config}
else {script.text = config}
View .gitignore
# macOS
# General
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
@Nil-Zil
Nil-Zil / tasks.json
Last active Jul 26, 2017
vscode tasks config
View tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "watchers",
"args": [],
"suppressTaskName": true,
"isShellCommand": false,
"tasks": [{
"taskName": "browserify",
View magnetic field of a solenoid.nb
plist = Table[{(4 i - 26)/6, -(-1)^i}, {i, 1, 12}];
r[{xi_, yi_}] := Sqrt[(x - xi)^2 + (y - yi)^2];
DensityPlot[
2 Sqrt[((Plus @@
Map[#[[2]] (x - #[[1]])/r[#]^2 &, plist])^2 + (Plus @@
Map[-#[[2]] (y - #[[2]])/r[#]^2 &, plist])^2)] +
Cos[18.8 Plus @@ Map[#[[2]]/r[#] &, plist]] + 1, {x, -6, 6}, {y, -3,
3}, Mesh -> False, Frame -> False, PlotRange -> {0, 10},
PlotPoints -> {275, 138}, AspectRatio -> 1/2]
View mkoutputdir.py
#!/usr/bin/env python3
# created at Jun 6, 2017 00:45
import os
if not os.path.exists("build.noindex/"):
os.makedirs("build.noindex/")
View memfree.rb
#!/usr/bin/env ruby
# encoding: utf-8
if `uname`.strip == "Darwin"
def get_paged_memory_usage(match_string, paging=4096)
mvar = 3
if match_string.split(/[^\w]/).length > 1
mvar = 4
end
paged_val = `vm_stat | grep "Pages #{match_string}:" | awk '{ print $#{mvar}}'`.to_i
View curve_fit.py
import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
def func(x, a, b, c):
return a * np.exp(-b * x) + c
x_data = np.linspace(0, 10, 20)
y_data = [1.005530886735986, 0.36271009697000134, 0.10282751652440644, 0.03638464925638259, 0.0177328764419975, 0.007038622747455951, -0.011725650107022643, 0.017847156954980542, -0.0006555003543666825, 0.021014391787336193, -
View sort_listD_by_list_A.py
#!/usr/bin/env python3
# created at Jun 23, 2017 21:04 by Nil-Zil
"""
Sort list d, e, f by the elements in a, b, c.
"""
from operator import itemgetter
import numpy as np
You can’t perform that action at this time.