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
| # coding: UTF-8 | |
| import socket | |
| import struct | |
| def aton(addr): | |
| return struct.unpack('!l', socket.inet_aton(addr)) | |
| def ntoa(addr): | |
| return socket.inet_ntoa(struct.pack('!l', addr)) |
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/sh | |
| # certs.sh | |
| # use this for Yocto/Edison: | |
| LIB=lib | |
| # use this for WRLinux/Gateway | |
| # LIB=lib64 | |
| if [ -f /usr/$LIB/jvm/java-8-openjdk/jre/lib/security/cacerts ]; then | |
| mv /usr/$LIB/jvm/java-8-openjdk/jre/lib/security/cacerts \ |
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
| var fs = require('fs'); | |
| var INTERVAL = 1000; | |
| var cycle_stop = false; | |
| var daemon = false; | |
| var timer; | |
| process.argv.forEach(function (arg) { | |
| if (arg === '-d') daemon = true; |
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
| <?php | |
| // ... | |
| protected function getMockedPDO() | |
| { | |
| $query = $this->getMock('\PDOStatement'); | |
| $query->method('execute')->willReturn(true); | |
| $db = $this->getMockBuilder('\PDO') | |
| ->disableOriginalConstructor() |
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
| $.fn.select2.amd.define('select2/data/extended-ajax',['./ajax','../utils','jquery'], function(AjaxAdapter, Utils, $){ | |
| function ExtendedAjaxAdapter ($element,options) { | |
| //we need explicitly process minimumInputLength value | |
| //to decide should we use AjaxAdapter or return defaultResults, | |
| //so it is impossible to use MinimumLength decorator here | |
| this.minimumInputLength = options.get('minimumInputLength'); | |
| this.defaultResults = options.get('defaultResults'); | |
| ExtendedAjaxAdapter.__super__.constructor.call(this,$element,options); |
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
| (function($){ | |
| $(function(){ | |
| $.ajax({ | |
| contentType: 'application/text; charset=utf-8', | |
| crossBrowser: true, | |
| type: 'GET', | |
| url: '/cdn-cgi/trace', | |
| }).done(function(d){ | |
| var data = d.replace(/[\r\n]+/g, '","').replace(/\=+/g, '":"'); | |
| data = '{"' + data.slice(0, data.lastIndexOf('","')) + '"}'; |
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
| <?php | |
| function combos($data, &$all = array(), $group = array(), $val = null, $i = 0) { | |
| if (isset($val)) { | |
| array_push($group, $val); | |
| } | |
| if ($i >= count($data)) { | |
| array_push($all, $group); | |
| } else { | |
| foreach ($data[$i] as $v) { |
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
| /** | |
| * Check if a given ip is in a network | |
| * @param string $ip IP to check in IPV4 format eg. 127.0.0.1 | |
| * @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed | |
| * @return boolean true if the ip is in this range / false if not. | |
| */ | |
| function ip_in_range( $ip, $range ) { | |
| if ( strpos( $range, '/' ) == false ) { | |
| $range .= '/32'; | |
| } |
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/sh | |
| # This program has two feature. | |
| # | |
| # 1. Create a disk image on RAM. | |
| # 2. Mount that disk image. | |
| # | |
| # Usage: | |
| # $0 <dir> <size> | |
| # |
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/sh | |
| import(){ | |
| img_name=$1 | |
| vm_id=$2 | |
| storage=${3:-local-lvm} | |
| vmdisk_name=img2kvm_temp.qcow2 | |
| if [ "${img_name##*.}"x = "gz"x ];then |
OlderNewer