cat

Why can't you use cat to read a file line by line where each line has delimiters

不羁岁月 提交于 2019-12-03 07:12:22
问题 I have a text file that contains something like this: abc 123, comma the quick brown fox jumped over the lazy dog comma, comma I wrote a script for i in `cat file` do echo $i done For some reason, the output of the script doesn't output the file line by line but breaks it off at the commas, as well as the newline. Why is cat or "for blah in cat xyz " doing this and how can I make it NOT do this? I know I can use a while read line do blah balh blah done < file but I want to know why cat or the

Sequelize bulkCreate() returns NULL value for primary key

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am writing rest using node, sequelize as ORM for mySQL. I am using bulkCreate function to create record in bulk. But in response it is returning null for primary key value. Model sequelize.define('category', { cat_id:{ type:DataTypes.INTEGER, field:'cat_id', primaryKey: true, autoIncrement: true, unique:true }, cat_name:{ type: DataTypes.STRING, field: 'cat_name', defaultValue:null } }); Bulk Create operation : var data = [ { 'cat_name':'fashion' }, { 'cat_name':'food' } ]; orm.models.category.bulkCreate(data) .then(function(response){ res

PHP: How to find most used array key?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Lets say I have a simple 1D array with 10-20 entries. Some will be duplicate, How would I find out which entry is used the most? like.. $code = Array("test" , "cat" , "test" , "this", "that", "then"); How would I show "test" as the most used entry? 回答1: $code = Array("test" , "cat" , "test" , "this", "that", "then"); function array_most_common($input) { $counted = array_count_values($input); arsort($counted); return(key($counted)); } echo '<pre>'; print_r(array_most_common($code)); 回答2: You can get a count of the number of occurrences of

I get an error “None of the input catalogs contained a matching launch image” in xCode5-iOS7

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to define launch images. Probably only one image is missing. I'm following the instructions from this site Create launch images in different sizes for different devices So I have 7 images with the required size. But when I drag them to LaonchImages sheet it requires 8 images...the one that is missing is called "iPhone Portrait 2x" and according to the details pane I found its size 640x960 and I added it. sill I'm getting the error - and the compilation fails... 回答1: Select your project, go to Build Settings, search for AppIcon-2

How to make sure that Tomcat6 reads CATALINA_OPTS on Windows?

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Tomcat6 running on a Windows2003 machine. I deployed 2 Grails apps on this server and I soon noticed that everything was crashing sometime after the deploy with a classic PermGen error. java.lang.OutOfMemoryError: PermGen space java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.de ... So I found a common fix for this problem: increasing heap and permgen space

Learning pipes, exec, fork, and trying to chain three processes together

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm learning to use pipes and following along with this code on pipes . The program makes two child processes using fork. The first child runs 'ls' command and outputs to pipe1. The second reads from pipe1 runs 'wc' and outputs to stdout. I'm just trying to add a third process in the middle that reads from pipe1 and outputs to pipe2. Basically what I'm trying to do ls | cat | wc -l What I'm trying to do: (ls)stdout -> pipe1 -> stdin(cat)stdout-> stdin(wc -l) -> stdout Nothing ever prints to stdout and the program never exits. Here's my code

Class is not Abstract and does not Override error in Java

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting a compile time error with Java: MyClass is not abstract and does not override abstract method onClassicControllerRemovedEvent( wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent) in wiiusejevents.utils.WiimoteListener) Here is the class: import wiiusej.WiiUseApiManager; import wiiusej.Wiimote; import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; import wiiusej.wiiusejevents.physicalevents.IREvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents

string to array, split by single and double quotes

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i'm trying to use php to split a string into array components using either " or ' as the delimiter. i just want to split by the outermost string. here are four examples and the desired result for each: $pattern = "?????"; $str = "the cat 'sat on' the mat"; $res = preg_split($pattern, $str); print_r($res); /*output: Array ( [0] => the cat [1] => 'sat on' [2] => the mat )*/ $str = "the cat \"sat on\" the mat"; $res = preg_split($pattern, $str); print_r($res); /*output: Array ( [0] => the cat [1] => "sat on" [2] => the mat )*/ $str = "the \"cat

Error pasting “”HELLO“” and “”WORLD“” does not give a valid preprocessing token

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is the faulty code #include<stdio.h> #define CAT_I(A, B) A ## B #define CAT(A, B) CAT_I(A,B) void main (void) { printf(CAT("HELLO","WORLD")); } Why it gives that error? How could I fix it? EDIT This is what I am trying to do #define TAG "TAG" #define PRE CAT(CAT("<",TAG),">") #define POS CAT(CAT("</",TAG),">") #define XML CAT(CAT(PRE,"XML SOMETHING"),POS) then printf(XML); 回答1: The result of ## must be a single token, and "HELLO""WORLD" is not a single token. To concatenate strings, simply leave them beside each other: printf("HELLO"

Stratified sampling - not enough observations

匿名 (未验证) 提交于 2019-12-03 02:28:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What I would like to achieve is get a 10% sample from each group (which is a combination of 2 factors - recency and frequency category). So far I have thought about package sampling and function strata() . Which looks promising but I am getting the following error and it is really hard to understand the error message and what is wrong or how to get around this. Here is my code: > d[1:10,] date id_email_op recency frequecy r_cat f_cat 1 29.8.2011 19393 294 1 A G 2 29.8.2011 19394 230 4 A D 3 29.8.2011 19395 238 12 A B 4 29.8.2011 19396 294 1