#!/usr/bin/env python
import os, sys, subprocess, time
while True:
print subprocess.call("xsel", shell=True);
time.sleep(1);
Takes an entry from the clipboard and prints it, every 1 second.
Result:
copied0
entry0
from0
clipboard0
I do not know why it returns the final 0, but it apparently stops me from using string stri...
Is it better, from a performance standpoint, to use "Example1"? I'm assuming that "Example2" would create a new string on the heap in each iteration while "Example1" would not...
Example1:
StringBuilder letsCount = new StringBuilder("Let's count! ");
string sep = ", ";
for(int i=; i< 100; i++)
{
letsCount.Append(i + sep);
}
Exa...
def checkCache(cachedText):
for line in open("cache"):
if cachedText + ":" in line:
print line
open("cache").close()
else:
requestDefinition(cachedText)
This code searches each line of a file (cache) for a specific string (cachedText + ":").
If it does not find the specific stri...
I have trouble understanding the compilers.
The following code does work in UNIX under g++, but under VC++ it would not even compile. Anyone can provide valid reasons why?
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string tmp_nw_msg, crc_chksum, buffer;
cout << "Enter the str...
I have some fairly simple (at least when you skip error checking, event stuff, et cetera) parameter classes. They are "assembled" kind of like this:
public interface IParameter
{
Type ValueType { get; }
object Value { get; set; }
}
public interface IParameter<TValue> : IParameter
{
new TValue Value { get; set; }
}
public a...
Hi,
I might be asking this question incorrectly but what I would like to do is the following:
Given a large String which could be many 100s of lines long match and replace a word exactly and make sure it does not replace and match any part of any other String.
For example :
Strings to Find = Mac Apple Microsoft Matt Damon I.B.M. Hur...
In Python I have four strings that include the formatting of a list:
line1 ="['a.b.c','b.c.a','c.d.e']"
line2 ="['def','efg']"
line3 ="['f']"
line4 ="['g']"
How do I merge them all so I get a valid Python list such as:
SumLine = ['a.b.c','b.c.a','c.d.e','def','efg','f','g']
...
Can anyone please tell me how to multiply two number arrays in C? The number arrays are basically derived from two strings containing digits. eg: 123456 and 132465.
Edit: I had two string as S1 = "123456" and S2="132546". I then converted these two strings into array of ints i.e. int IS1[6] and IS2[6] so that
IS1[1] = 1, IS1[2] = 2......
In C#, strings are reference type but behaves like value type.
e.g.
string str = "I am a string";
str.Replace("am", "was"); //str still contains same value,
//i want it to make "I was a string"
I know i can do this by
str = str.Replace("am", "was");
But i don't want to re-assign it.
Is there anyway to make them behave like Refere...
I'm looking for a nice template engine or short piece of code to expand Ant-like variables in a string in Java. Example:
String result = expand ("${firstName} ${familyName}", map);
It should at least support java.util.Map but something that can handle beans or recursive lookups or lookups in a list of maps/objects would be welcome, to...
I want to multiply strings using functions.with user giving the string and the power to that string.and display it.
...
Hi i have string
s='This is sample'
i need to convert like this
s='"This is sample"'
output="This is sample"
how to do this in dynamic
Thanks in advance
...
I'm reading a textfile on the format
Phone#(tab)Text(line break)
(line break)
Or more specifically
4799999999 Hey! You owe us $576.53. Pay up to account no. 9760.00.12345, ID: 201561438.
4798888888 Hey! You owe us $199. Pay up to account no. 9760.05.12345, KID: 201565173.
4797777777 Hey! You owe us... and so on.
I want to store...
i have tried startswith , find , re.sub but all seems to be find that string that matches part of it . iam looking for command which searchs the exact string which iam searching for in a given file.
Thanks for your help.
...
Hi,
I tried to parse string to TimeSpan like the following :
Dim dt As DateTime = DateTime.Now
Dim timeCheckin As String = Format(dt, "HH:MM:FF")
ts = TimeSpan.Parse(timeCheckin)
It threw error like this:
System.OverflowException: The TimeSpan could not be parsed because at least one of the hours, minutes, or seconds ...
Due to the sheer annoyance of figuring out what to Google, I've decided to risk what any reputation I had to ask this rather simple question.
As PEP8 suggests keeping below the 80 column rule for your python program, how can I abide to that with long strings, i.e.
s = "this is my really, really, really, really, really, really, really l...
For a given file
For ex : 11 ,345 , sdfsfsfs , 1232
i need to such above records from a file , read 11 to delimiter and strip the white space and store in the another file , similarly 345 to delimiter strip the while space and store in the file. This way i need to do for multiple rows.
so finally in the other file the data should ...
Are there any Cocoa classes that will help me convert a hex value in a NSString like 0x12FA to a long or NSNumber? It doesn't look like any of the classes like NSNumberFormatter support hex numbers.
Thanks,
Hua-Ying
...
I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.
I try:
strid = repr(595)
print array.array('c', random.sample(string.ascii_letters, 20 - len(strid)))
.tostring().join(strid)
and get something like:
5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5
Why does...
Hi,
I'm currently learning Ruby, and am enjoying most everything except a small string comparason issue.
answer = gets()
if (answer == "M")
print("Please enter how many numbers you'd like to multiply: ")
elsif (answer. == "A")
print("Please enter how many numbers you'd like to sum: ")
else
print("Invalid answer....