Skip to content

Instantly share code, notes, and snippets.

@sepulchered
sepulchered / FileSizeRenderer
Created October 18, 2013 15:01
Ext.js custom renderer for file size
function(val) {
var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'],
ind = 0;
while (val >= 1024 && ind < units.length -1) {
val = val / 1024;
ind++;
}
return val.toFixed(3) + ' ' + units[ind];
}
@sepulchered
sepulchered / CanvasAnimation.html
Created February 13, 2014 07:21
Simple Canvas Manipulation
<!doctype html>
<html>
<head>
<title>canv1</title>
</head>
<body>
<canvas id='panel'></canvas>
<script type="text/javascript">
var PANEL = {
currentWidth: 800,
@sepulchered
sepulchered / bifrF.markdown
Created May 26, 2014 08:37
A Pen by Andrey Dresvyannikov.
-- Main.elm
update : Msg -> Model -> Model
update msg model =
case msg of
QuestionMsg qMsg ->
{ model
| questions = Question.update qMsg model.questions
}
ProceedToNextQuestion msg ->
@sepulchered
sepulchered / Jenkinsfile
Last active November 15, 2023 10:25
Sample Jenkinsfile for node.js projects
#!/usr/bin/env groovy
pipeline {
agent any
environment {
NODE_ENV_PATH = './venv'
NODE_VERSION = '6.11.1'
}
stages {
stage('Pre-cleanup') {
steps {
import time
import subprocess
def install_bower_deps():
""" Installs bower dependencies. """
subprocess.run(['echo', '--- bower install ---'])
time.sleep(5) # subprocess.run(['bower', 'install'])
subprocess.run(['echo', '--- /bower install ---'])
import time
import asyncio
import subprocess
async def install_bower_deps():
""" Installs bower dependencies. """
subprocess.run(['echo', '--- bower install ---'])
await asyncio.sleep(5) # subprocess.run(['bower', 'install'])
subprocess.run(['echo', '--- /bower install ---'])
import time
import asyncio
import subprocess
async def install_bower_deps():
""" Installs bower dependencies. """
subprocess.run(['echo', '--- bower install ---'])
await asyncio.sleep(5) # subprocess.run(['bower', 'install'])
subprocess.run(['echo', '--- /bower install ---'])
import typing
def divide(num: float, den: float) -> typing.Optional[float]:
return num / den
print(divide(1, 2))
print(divide(1, 0))