Skip to content

Instantly share code, notes, and snippets.

View nathnx's full-sized avatar

nathnx nathnx

View GitHub Profile
@nathnx
nathnx / battery.py
Created January 20, 2017 03:40 — forked from lloeki/battery.py
Battery status script for Mac OS X
#!/usr/bin/env python
from __future__ import print_function
from __future__ import division
from subprocess import Popen, PIPE
def ioreg_battery_info():
output = Popen(["ioreg", "-r", "-k", "LegacyBatteryInfo", "-w", "0"], stdout=PIPE).communicate()[0]
try: #python3
#### Array ####
# create data vector
data1 <- c(187,321,431,211)
data2 <- c(100,587,498,967,3567,4030,3888,3021,8765,9999,7867,8799)
data3 <- seq(4560, 7650, length.out = 16) # seq for generate sequence of number
data4 <- ceiling(seq(14640, 25600, length.out = 16)) #ceiling for roundup number
myarray <- array(c(data1,data2, data3, data4),
dim = c(4,4,3),
#### Create Function ####
# first approch
fn1 <- function (myinput) { myinput * 999 }
# how to use it
fn1(E)
fn1(myinput = E)