This file contains hidden or 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
| class Just | |
| def initialize(value) | |
| @value = value | |
| end | |
| def map(methodsymbol=nil, *args, &block) | |
| if((not methodsymbol.nil?) and block_given?) | |
| raise BlockMethod, "argument should be either methodsymbol, or block process" | |
| end |
This file contains hidden or 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 main(somestring): | |
| g = globals() | |
| for i, char in enumerate(somestring): | |
| if(ord(char) in range(ord("0"), ord("9"))): | |
| variable_name = "my_int_{}".format(i) | |
| g[variable_name] = int(char) | |
| else: | |
| variable_name = "my_char_{}".format(i) | |
| g[variable_name] = char | |
| print(my_char_0) |
This file contains hidden or 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
| import os | |
| import re | |
| class HorribleSubs: | |
| regex = re.compile("\[HorribleSubs\] (.+) - (\d+) \[\d+p\].*(\.\w+$)") | |
| def __init__(self, path): | |
| parsed = HorribleSubs.regex.findall(path) | |
| title, episode, extension = parsed[0] |
This file contains hidden or 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
| require "hashie" | |
| require "memoist" | |
| class HashQuery | |
| attr_reader(:path) | |
| # @param root [NestedHash] | |
| # @param query [String] | |
| def initialize(root, path) | |
| @root = root | |
| @path = path |
This file contains hidden or 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
| #!/bin/bash | |
| # Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04 | |
| # Inspired from https://gist.github.com/faleev/3435377 | |
| # Remove any existing packages: | |
| sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev | |
| # Get the dependencies (Ubuntu Server or headless users): | |
| sudo apt-get update |
This file contains hidden or 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
| require 'memoist' | |
| class HTMLParser | |
| extend Memoist | |
| ReversedParser = /(?<after>[^>]*)>(?<tag>[^\/]+)\/<(?<body>.*?)>(?<tag_attr>[^>]*)\k<tag><(?<before>.*)/ | |
| attr_reader(:raw_string) | |
| def initialize(raw_string) | |
| @raw_string = raw_string.gsub("\n", "") | |
| end |
This file contains hidden or 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
| import React from 'react'; | |
| import EnemyView from 'components/Seven/EnemyView'; | |
| import { bindActionCreators } from 'redux'; | |
| import { connect } from 'react-redux'; | |
| import EnemiesActions from 'actions/Seven/EnemiesActions'; | |
| @connect(state => ({})) | |
| export default class EnemiesView extends React.Component { | |
| render(){ |
This file contains hidden or 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
| import Immutable from 'immutable' | |
| import { Actions } from 'actions' | |
| const defaultState = new Immutable.List(); | |
| function reducer(state = defaultState, action){ | |
| if(action.type === Actions.STATE_REPLACE){ | |
| ... | |
| return replacedState; | |
| }else if(action.type === Actions.REMOVE_STATE){ | |
| ... | |
| return removedState; |
This file contains hidden or 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
| table.columns.each do |column| | |
| define_method("find_by_#{column.name}") do |value| | |
| ... # somecode | |
| connection.call("SELECT #{selected_fields} WHERE #{column.name} = #{value}") | |
| end | |
| end |
This file contains hidden or 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
| # user.rb | |
| def method_missing?(methodname) | |
| if(user_info.respond_to?(methodname)) | |
| user_info.send(methodname) | |
| else | |
| raise NoMethodError, methodname | |
| end | |
| end |