Go语言单个文件拷贝演示代码package mainimport "fmt"import "io"import "os"func main(){ w,err := CopyFile("filecopy.go","test.go") i……继续阅读 » 水墨上仙 8年前 (2018-01-20) 1695浏览 1491个赞
读取源文件,去掉空行,并写到目标文件/** * Created with IntelliJ IDEA. * User: hyper-carrot * Date: 12-8-31 * Time: 下午4:04 * To change this template use File | Settings | File Templates.……继续阅读 » 水墨上仙 8年前 (2018-01-20) 2125浏览 336个赞
websockets的bufferedAmount使用范例代码// 10k max buffer size.var THRESHOLD = 10240; // Create a New WebSocket connectionvar ws = new WebSocket("ws://w3mentor.com"); ……继续阅读 » 水墨上仙 8年前 (2018-01-20) 2803浏览 1899个赞
Go语言模仿linux cat命令package mainimport ( "io" "os" "fmt" "bufio" "flag")var numberFlag = flag.Bool("n"……继续阅读 » 水墨上仙 8年前 (2018-01-20) 2620浏览 1021个赞
程序会监听8080端口,然后简单的返回web/路径下的文件,假如只输入类似localhost:8080,会自动找到index.htmlpackage mainimport ( "net/http")func main() { http.Handle("/", http.FileServ……继续阅读 » 水墨上仙 8年前 (2018-01-09) 2593浏览 436个赞
android studio 3.0 出现“应用未安装”情况处理1、清理项目,Cleaned the Project2、删除项目的build文件夹,Deleted the Build directory3、重启android Studio ,Restarted Android Studio4、重新生成项目,Rebuild the ProjectR……继续阅读 » 开心洋葱 8年前 (2017-10-29) 2111浏览 0评论1995个赞
php配置方法:配置方法:1. 进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息:name: localhost,host: localhost,port: 80,debugger: XDebug2. 进入File>Settings>PHP>Debug,找到XDebug选项卡,port填9000进入File……继续阅读 » 开心洋葱 8年前 (2017-10-28) 2689浏览 0评论338个赞
/** 密码发生器 在对银行账户等重要权限设置密码的时候,我们常常遇到这样的烦恼:如果为了好记用生日吧,* 容易被破解,不安全;如果设置不好记的密码,又担心自己也会忘记;如果写在纸上,担心纸张被别人发现或弄丢了…* 这个程序的任务就是把一串拼音字母转换为6位数字(密码)。* 我们可以使用任何好记的拼音串(比如名字,王喜明,就写:wangx……继续阅读 » 水墨上仙 9年前 (2017-07-11) 2715浏览 425个赞
//// main.c// test1//// Created by yt on 2017/.// Copyright © 2017年 yt. All rights reserved.//#include <stdio.h>#include <time.h>#include <stdlib.h>……继续阅读 » 开心洋葱 9年前 (2017-07-08) 1817浏览 0评论489个赞
golang日志记录库简单使用方法范例package mainimport ( "fmt" "log" "os")func main(){ logfile,err := os.OpenFile("/var/golang/75271.com.log",……继续阅读 » 水墨上仙 9年前 (2017-07-04) 2882浏览 287个赞
Methods with the same name as their class will not be constructors in a futusupports_collation is deprecated since version 3.5.0! Use wpdb::has_cap( ‘collation’ ) inst……继续阅读 » 开心洋葱 9年前 (2017-06-16) 1458浏览 0评论190个赞
Java求1000以内的水仙花数打印出所有的 “水仙花数 “,所谓 “水仙花数 “是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 “水仙花数 “,因为153=1的三次方+5的三次方+3的三次方。public class 水仙花数 { public static v……继续阅读 » 水墨上仙 9年前 (2017-06-09) 2620浏览 1599个赞
Temporary breakpoint 2 at 0x100000ef4: file sort_select.c, line 30.Starting program: /Users/yt/Documents/CodeProj/c/sort_select During startup program terminated with signal SIG1……继续阅读 » 开心洋葱 9年前 (2017-06-04) 2425浏览 0评论1302个赞
字符串编辑距离 这是一种字符串之间相似度计算的方法。 给定字符串S、T,将S转换T所需要的插入、删除、替代操作的数量叫做S到T的编辑路径。 其中最短的路径叫做编辑距离。 这里使用了一种动态规划的思想求编辑距离。package com.mycompany.project;/** * 字符串编辑距离 * * 这是一种字符串之间相似度计算的方法……继续阅读 » 水墨上仙 9年前 (2017-06-04) 2700浏览 736个赞
二、编译警告:warning C4996 与 Security Enhancements in the CRT将过去的工程用VS2005打开的时候。你有可能会遇到一大堆的警告:warning C4996。比如:warning C4996: ‘strcpy’: This function or variable may be un……继续阅读 » 开心洋葱 9年前 (2017-06-02) 2810浏览 0评论2210个赞
用样式控制网页部分区域不被打印,我们经常需要在打印的网页上面放置一个打印按钮,如何让这个按钮不被同时打印出来,可以用一句样式解决。定义如下样式.noprint{display:none;} 只需要给不想打印的标签贴上noprint的class就可以了 <div class="noprint"> <i……继续阅读 » 水墨上仙 9年前 (2017-06-01) 1849浏览 1169个赞
打印出所有的 “水仙花数 “,所谓 “水仙花数 “是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 “水仙花数 “,因为153=1的三次方+5的三次方+3的三次方。public class exp2{ public static void main(Strin……继续阅读 » 水墨上仙 9年前 (2017-05-31) 2674浏览 342个赞
C语言回溯法解决背包问题#include #include #include using namespace std;#define MAXN 10struct Goods_Info{ int v; //价值 int w; //重量 double vw; //价值重量比}goods[MAXN];int n;……继续阅读 » 水墨上仙 9年前 (2017-05-31) 2705浏览 2739个赞
100 可以表示为带分数的形式:100 = 3 + 69258 / 714 还可以表示为:100 = 82 + 3546 / 197 注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。 类似这样的带分数,100 有 11 种表示法。#include#include/*检查某个数是否出现重位的情况,可以与nKill整合,但这儿单独列出*……继续阅读 » 水墨上仙 9年前 (2017-05-31) 2689浏览 406个赞
JS代码返回iframe的name属性(名称)<!DOCTYPE html><html><body><iframe id="myframe" src="/default.asp" name="myframe"><p>……继续阅读 » 水墨上仙 9年前 (2017-05-31) 3113浏览 1318个赞
0-1背包问题:给定n种物品和一背包.物品i的重量是wi, 其价值为ui,背包的容量为C. 问如何选择装入背包的物品,使得装入背包中物品的总价值最大? 分析: 0-1背包是子集合选取问题,一般情况下0-1背包是个NP问题. 第一步 确定解空间:装入哪几种物品 第二步 确定易于搜索的解空间结构: 可以用数组p,w分别表示各个物品价值和重量。 用数组x记录,是否……继续阅读 » 水墨上仙 9年前 (2017-05-31) 3286浏览 2213个赞
$file = Input::file(‘myfile’);if($file -> isValid()){ //检验一下上传的文件是否有效.$clientName = $file -> getClientOriginalName();$tmpName = $file ->getFileName(); // 缓存……继续阅读 » 开心洋葱 9年前 (2017-05-31) 1596浏览 0评论2778个赞
Input输入 输入设备(如按键,键盘,触摸屏,鼠标等)是典型的字符设备,其一般的工作机制是低层在按键,触摸等动作发生时产生一个中断(或驱动通过timer定时查询),然后cpu通过SPI,I2C或者外部存储器总线读取键值,坐标等数据,放一个缓冲区,字符设备驱动管理该缓冲区,而驱动的read()接口让用户可以读取键值,坐标等数据。 Linux 输入子……继续阅读 » 开心洋葱 9年前 (2017-05-29) 3026浏览 0评论299个赞
通过JS代码控制iframe居左或者居右显示,下面的代码控制iframe居右显示,如果希望居左显示,只需要将right改成left即可<!DOCTYPE html><html><body><p>This is some text. This is some text. This is so……继续阅读 » 水墨上仙 9年前 (2017-05-27) 3296浏览 588个赞
如果希望通过按钮动态修改iframe的高度和宽度,可以参考下面的JS代码<!DOCTYPE html><html><head><script>function changeSize(){document.getElementById("myframe").hei……继续阅读 » 水墨上仙 9年前 (2017-05-27) 1796浏览 1240个赞
Java使用逆波兰表达式算法制作的表达式计算器package com.infogrid.g2b; import java.util.HashMap; import java.util.Map; public class Op { private static final Ma……继续阅读 » 水墨上仙 9年前 (2017-05-27) 2379浏览 792个赞
下面的代码可以用来去除iframe的滚动条<!DOCTYPE html><html><head><script>function removeScroll(){document.getElementById("myframe").scrolling="……继续阅读 » 水墨上仙 9年前 (2017-05-27) 3174浏览 2828个赞
============================================================GeoHash PHP ClassProvides a class for generating and decoding geohashes asdocumented at http://en.wikipedia.org/wiki/……继续阅读 » 开心洋葱 9年前 (2017-05-22) 3052浏览 0评论2001个赞
php按单词截取字符串的代码,指定字符串和单词数量进行截取<?phpfunction limit_words($string, $word_limit){ $words = explode(" ",$string); return implode(" ",array_splice($……继续阅读 » 水墨上仙 9年前 (2017-05-09) 2209浏览 876个赞
php生成随机密码的函数function auth_pwgen(){ $pw = ''; $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones $v = 'aeiou'; ……继续阅读 » 水墨上仙 9年前 (2017-05-09) 2320浏览 1756个赞
php检查要包含的文件是否存在可读……继续阅读 » 水墨上仙 9年前 (2017-05-09) 2792浏览 1117个赞
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: AuthTest::testLoginPageFacebook\WebDriver\Exception\WebDriverC……继续阅读 » 开心洋葱 9年前 (2017-05-08) 2296浏览 0评论2514个赞
如果文件大小为字节单位的,阅读起来不方便,这个函数可以把字节单位转换成KB,MB,GB,TB等单位,方便阅读function ByteSize ( $file_size ){ $file_size = $file_size-1; if ($file_size >= 1099511627776) $show_filesize = nu……继续阅读 » 水墨上仙 9年前 (2017-05-05) 1506浏览 900个赞
php将文件夹下的所有图片放入数组function listImages($dirname=".") { $ext = array("jpg", "png", "jpeg", "gif"); $files = array(); ……继续阅读 » 水墨上仙 9年前 (2017-05-05) 2603浏览 2019个赞
指定一个文件夹,在php里include这个文件夹下的所有.php文件foreach (glob("*.php") as $filename) { include($filename);}……继续阅读 » 水墨上仙 9年前 (2017-05-05) 2516浏览 1389个赞
php检测浏览器类型代码// Simple browser detection$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = false; if (strpos($_SERVER['HTTP_U……继续阅读 » 水墨上仙 9年前 (2017-05-05) 2918浏览 1772个赞
php动态生成表单代码<?php define('VALID_NOT_EMPTY', '/.+/'); define('VALID_EMAIL', "/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&&……继续阅读 » 水墨上仙 9年前 (2017-05-04) 2040浏览 2822个赞
php动态改变图片尺寸后输出,输出图片时使用下面的地址:image_resize.php?img=image.jpg&w=150&h=150&constrain=1w和h为要显示的尺寸 0) { // calculate resized height and width if percent is defined ……继续阅读 » 水墨上仙 9年前 (2017-05-04) 2778浏览 2580个赞
php不破坏单词截取子字符串的方法/* snippet(phrase,[max length],[phrase tail]) snippetgreedy(phrase,[max length before next space],[phrase tail]) */ function snippet($text,$le……继续阅读 » 水墨上仙 9年前 (2017-05-04) 2408浏览 981个赞
php 将数组转换成xml的类class ArrayToXML{ /** * The main function for converting to an XML document. * Pass in a multi dimensional array and this recrusively loops through and bu……继续阅读 » 水墨上仙 9年前 (2017-05-03) 1359浏览 1576个赞
Migration table not found.Migration table created successfully. [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was ……继续阅读 » 开心洋葱 9年前 (2017-04-24) 1526浏览 0评论505个赞
(node:23771) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.> node-sass@3.13.1 ins……继续阅读 » 开心洋葱 9年前 (2017-04-22) 2398浏览 0评论1097个赞
You can however run a command with sudo using –allow-root optionError: post install error, please remove node_modules before retry!Run “sh -c bower install &……继续阅读 » 开心洋葱 9年前 (2017-04-22) 2205浏览 0评论1230个赞
Do not run Composer as root/super user! See https://getcomposer.org/root for detailsLoading composer repositories with package informationInstalling dependencies (including requi……继续阅读 » 开心洋葱 9年前 (2017-04-22) 2400浏览 0评论1867个赞
堆栈计算逆波兰式使用C语言实现逆波兰式(Reverse Polish notation,RPN,或逆波兰记法),也叫后缀表达式(将运算符写在操作数之后)一个表达式E的后缀形式可以如下定义:(1)如果E是一个变量或常量,则E的后缀式是E本身。(2)如果E是E1 op E2形式的表达式,这里op是如何二元操作符,则E的后缀式为E1’E2……继续阅读 » 水墨上仙 9年前 (2017-04-20) 2935浏览 205个赞