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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import readline # for better console text edit experience | |
def isnumeric(number): | |
for num in range(10): | |
if str(number[-1])==str(num): | |
return True |
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
def stringify(obj): | |
return str(obj) | |
def parse(string): | |
if string[0] == ' ': | |
raise Exception('cannot parse') | |
for i in __builtins__.__dict__: | |
if string.startswith(i+'('): | |
raise Exception('cannot parse') | |
if string.startswith(i+' '): |
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
""" Python Script Object Notation (PSON) """ | |
# JSON alternative for Python. | |
def stringify(obj): | |
return str(obj) | |
def parse(string): | |
if string[0] == ' ': |
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
def camel_to_snake(str): | |
""" | |
camelCase to snake_case | |
'camelCase' -> 'camel_case' | |
""" | |
return ''.join(map(lambda char:char if char.islower() else "_"+char.lower(), str)) | |
def snake_to_camel(str): | |
""" |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
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 negative-map($map) { | |
$result: (); | |
@each $key, $value in $map { | |
@if $value != 0 { | |
$result: map-merge($result, ("-" + $key: (-$value))); | |
} | |
} | |
@return $result; | |
} |
OlderNewer