text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
else snd (head t))
GT -> let (u,z) = ins n x t
in ((v,s+x):u,z)
```
This is used in a loop, to process a list of numbers of known length, (changed it to foldl now)
```
scanl g (0,([],[])) ns -- ns :: [Int]
g ::
(Num t, Ord t, Ord a) =>
(t, ([(a, t)], [(a, t)])) -> a -> (t, ([(a, t)], [(a, t)]))
... | [
-0.35323578119277954,
-0.28863367438316345,
0.35951292514801025,
-0.31436318159103394,
-0.17205260694026947,
0.1499907523393631,
0.2784077227115631,
-0.60240238904953,
-0.440318763256073,
-0.391200989484787,
-0.3486156463623047,
0.28897932171821594,
-0.1875864416360855,
0.03592785075306892... | |
(b2,y) = if x>0 then ins n x b else (b,0)
c2 = c + y
in
(c2,( a2, b2))
```
This works, but I need to speed it up. In C, I would keep the lists `(a,b)` as arrays; use binary search to find the element with the key just above or equal to `n` (instead of the sequential search used here); and use in-p... | [
-0.12927383184432983,
0.17430660128593445,
0.1986755132675171,
-0.3002442717552185,
0.004037031438201666,
0.03661521151661873,
-0.0036049592308700085,
-0.5368490219116211,
-0.1512427031993866,
-0.41395893692970276,
-0.16837050020694733,
0.5881270170211792,
-0.3047266900539398,
-0.038146793... | |
is this done in Haskell, with mutable arrays?
I tried something, but I really don't know what I'm doing here, and am getting strange and very long error messages (like "can not deduce ... from context ..."):
```
goarr top = runSTArray $ do
let sz = 10000
a <- newArray (1,sz) (0,0) :: ST s (STArray s Int (Integer... | [
-0.0977027639746666,
-0.027201009914278984,
0.3131134808063507,
-0.08567993342876434,
0.08836212754249573,
-0.05837797746062279,
0.44666364789009094,
-0.06360764056444168,
-0.2566317319869995,
-0.3099232316017151,
-0.12725943326950073,
0.3341224789619446,
-0.48511114716529846,
-0.042726270... | |
=
if i >= top
then
do
return c
else
go2 p1 i c top a b
go2 p1 i c top a b =
do
let p2 = somefunc (i+1) -- p2 :: [(Integer, Int)]
let n = combine p1 p2 -- n :: Int
-- update arrays and calc new c
-- like the "g" | [
-0.1928754299879074,
-0.14280211925506592,
0.2040640413761139,
-0.23316670954227448,
-0.06132278963923454,
0.1503208875656128,
0.14645449817180634,
-0.6407320499420166,
-0.1205488070845604,
0.043060146272182465,
-0.29336312413215637,
0.5126901268959045,
-0.31572631001472473,
-0.42246261239... | |
function is doing:
-- (a2,x) = ins n 1 a
-- (b2,y) = if x>0 then ins n x b else (b,0)
-- c2 = c + y
go1 p2 (i+1) c2 top a b -- a2 b2??
```
This doesn't work at all. I don't even know how to encode loops in do notation. Please help.
**UPD:** the Map based code that runs 3 times slower:
```
... | [
-0.1958380937576294,
-0.216037780046463,
0.1425788253545761,
0.009043562225997448,
-0.16770371794700623,
0.043525271117687225,
0.4755418300628662,
-0.3519778251647949,
-0.369405597448349,
-0.2281150072813034,
-0.0793478786945343,
0.20447033643722534,
-0.621882975101471,
-0.0406386069953441... | |
(Map.Map k a, a)
ins3 n x a | Map.null a = (Map.insert n x a , 0)
ins3 n x a = let (p,q,r) = Map.splitLookup n a in
case q of
Nothing -> (Map.union (Map.map (+x) p)
(Map.insert n (x+leftmost r) r) , leftmost r)
Just s -> (Map.union (Map.map (+x) p)
(Map.insert n (x+s) r) ,... | [
-0.41007837653160095,
-0.39816901087760925,
0.26903486251831055,
0.057864949107170105,
-0.34040990471839905,
0.37340787053108215,
0.11969170719385147,
-0.5691363215446472,
-0.446726530790329,
-0.5233010649681091,
-0.5278228521347046,
0.14362524449825287,
-0.48990750312805176,
0.11304644495... | |
r)
leftmost r | Map.null r = 0
| otherwise = snd . head $ Map.toList r
```
**UPD2: The error message** is " Could not deduce (Num (STArray s1 i e)) from the context () arising from the literal `0' at filename.hs:417:11"
that's where it says `return c` in `go1` function. Perhaps `c` is expected to be an ... | [
-0.14302515983581543,
0.0762958899140358,
0.6629627346992493,
-0.21286650002002716,
0.20542608201503754,
0.06154765188694,
0.28538477420806885,
-0.4065519869327545,
-0.2215522676706314,
-0.23372361063957214,
-0.34774449467658997,
0.7212342619895935,
-0.11112840473651886,
0.1053083837032318... | |
it runs in constant space with sane empirical complexity and is actually projected to finish in under 0.5 hour - a.o.t. *... 3 days !* I knew about it of course but was so sure GHC optimizes the stuff away for me, *surely it wouldn't make that much of a difference*, I thought! And so felt only mutable arrays could help... | [
0.15739284455776215,
-0.05417587608098984,
0.6312307119369507,
0.09581033885478973,
0.04394686967134476,
-0.11337856948375702,
0.5737051367759705,
-0.03840838000178337,
-0.1125553697347641,
-0.6870971322059631,
0.06107630580663681,
0.37066641449928284,
0.13859115540981293,
-0.0781698673963... | |
mentioned Fenwick trees, I have used them to implement the algorithm. Two `STUArray` are allocated and mutated during the run. The basic Fenwick tree keeps totals for all smaller indices and the algorithm here needs totals for all larger indices. This change is handled by the `(sz-x)` subtraction.
```
import Control.M... | [
0.10277121514081955,
0.009863677434623241,
0.2267949879169464,
0.00049974286230281,
-0.288955956697464,
0.205185204744339,
0.5097235441207886,
-0.704923689365387,
0.060952816158533096,
-0.47908535599708557,
0.06237857788801193,
0.2743874788284302,
-0.48549097776412964,
-0.1871577352285385,... | |
-- Have (sz - (top+1)) > 0 to keep algorithm simple
sz = top + 2
-- Reversed Fenwick tree (no bounds checking)
insert :: STUArray s Int Int -> Int -> Int -> ST s ()
insert arr x v = loop (sz-x) where
loop i | i > sz = return ()
| i <= 0 = error "wtf"
| otherwise = do
oldVal <- u... | [
0.14705204963684082,
0.014788853004574776,
0.36526817083358765,
-0.24207037687301636,
-0.22881916165351868,
0.08364184200763702,
0.6989563703536987,
-0.5604557991027832,
0.021803997457027435,
-0.30986833572387695,
-0.2207351177930832,
0.38284948468208313,
-0.44717642664909363,
0.0101244766... | |
arr i
unsafeWrite arr i (oldVal + v)
loop (i + lsb i)
getSum :: STUArray s Int Int -> Int -> ST s Int
getSum arr x = loop (sz - x) 0 where
loop i acc | i <= 0 = return acc
| otherwise = do
val <- unsafeRead arr i
loop (i - | [
-0.25633665919303894,
0.018800243735313416,
0.5243101716041565,
-0.46980714797973633,
-0.23730269074440002,
0.35829660296440125,
0.9761090278625488,
-0.5870802402496338,
-0.0874420776963234,
-0.18239329755306244,
-0.02985997498035431,
0.5264638662338257,
-0.5795508623123169,
-0.04836036637... | |
lsb i) $! acc + val
ins n x arr = do
insert arr n x
getSum arr (succ n)
mutating :: ST s Int
mutating = do
-- Start index from 0 to make unsafeRead, unsafeWrite easy
a <- newArray (0,sz) 0 :: ST s (STUArray s Int Int)
b <- newArray (0,sz) 0 :: ST s (STUArray s Int Int)
let loop [] c = re... | [
-0.1662326455116272,
-0.12449321150779724,
0.3870273530483246,
-0.4529154300689697,
-0.008784113451838493,
0.3254258334636688,
0.6710488200187683,
-0.5415220260620117,
-0.21546442806720734,
-0.271090567111969,
-0.16858412325382233,
0.5731594562530518,
-0.6000193357467651,
0.005136798135936... | |
= do
x <- ins n 1 a
y <- if x > 0
then
ins n x b
else
return | [
-0.04143047705292702,
-0.20847177505493164,
0.0243977177888155,
-0.1548413783311844,
-0.15162095427513123,
0.2815750241279602,
0.49233323335647583,
-0.5558013916015625,
0.040248408913612366,
0.16879689693450928,
-0.3060566484928131,
0.29427143931388855,
-0.46090826392173767,
0.085983842611... | |
0
loop ns $! c + y
-- Without debugging use the next line
-- loop xs 0
-- With debugging use the next five lines
c <- loop xs 0
a' <- see a
b' <- see b
trace (show (c,(a',b'))) $ do
return c
-- see is only used in debugging
see arr = do
let zs = map | [
0.1467761993408203,
-0.1454847753047943,
0.4559979736804962,
-0.17695681750774384,
-0.06513271480798721,
-0.19393199682235718,
0.5656372308731079,
-0.43052545189857483,
-0.14177794754505157,
-0.4095236659049988,
-0.29172661900520325,
0.21584255993366241,
-0.37599286437034607,
-0.1218442395... | |
head . group . sort $ xs
vs <- sequence [ getSum arr z | z <- zs ]
let ans = filter (\(a,v) -> v>0) (zip zs vs)
return ans
up = [1..6]
down = [5,4..1]
see'tests = map go [ up, down, up ++ down, down ++ up ]
main = putStrLn . unlines . map show $ see'tests
``` | [
-0.08969870954751968,
-0.4211621880531311,
0.42328956723213196,
-0.32018688321113586,
0.14135104417800903,
0.025666391476988792,
0.4607188105583191,
-0.37962764501571655,
-0.3115064799785614,
-0.7338626384735107,
-0.30517470836639404,
-0.0022841074969619513,
-0.34528517723083496,
-0.177017... | |
I've got a new UI I'm working on implementing in Java and I'm having trouble implementing a JPopupMenu containing a JMenu (as well as several JMenuItems), which itself contains several JMenuItems. The JPopupMenu appears where I click the RMB, and it looks good, but the "Connect" JMenu doesn't seem to have any children ... | [
0.13588020205497742,
0.11766017973423004,
0.30560049414634705,
0.02409612573683262,
-0.06062451750040054,
0.2933482229709625,
0.4016762673854828,
-0.0884067490696907,
-0.2585272789001465,
-0.8486102223396301,
-0.01365789957344532,
0.5835853219032288,
0.026466485112905502,
0.008135288022458... | |
menu initialization method.
I've attached the pertinent code for your perusal.
```
//Elsewhere...
private JPopupMenu _clickMenu;
//End Elsehwere...
private void initializeMenu()
{
_clickMenu = new JPopupMenu();
_clickMenu.setVisible(false);
_clickMenu.add(generateConnectionMenu());
JMenuItem menuI... | [
-0.22904238104820251,
-0.27521586418151855,
0.6688471436500549,
-0.2800748646259308,
0.1112714558839798,
0.394737184047699,
0.21927420794963837,
-0.45972689986228943,
-0.2777734100818634,
-0.8255370855331421,
-0.5950836539268494,
0.6929823160171509,
-0.4201096296310425,
0.12290830910205841... | |
menu.add(new JMenuItem(portList.get(i).getName()));
}
return menu;
}
```
The code is certainly not the prettiest, but go easy on me as it's been altered too many times today as time permitted while I tried to figure out why this wasn't working. I'm thinking it may be a question of scope, but I've tried a few... | [
0.3507646918296814,
0.025287140160799026,
0.27565670013427734,
-0.13207745552062988,
0.012178576551377773,
0.023312943056225777,
0.3901614248752594,
0.09775570780038834,
-0.19072659313678741,
-0.9550655484199524,
-0.16851913928985596,
0.8211030960083008,
-0.23543502390384674,
0.14337280392... | |
was manually positioning and making the `JPopupMenu` visible instead of using the `JComponent.setComponentPopupMenu(menu)` method. After doing this for the card module in the above image (itself a JButton), the submenu displays correctly. A different, functional version of the initialization code is included below.
``... | [
-0.19135087728500366,
-0.41013434529304504,
0.5795901417732239,
-0.2954452335834503,
0.15546293556690216,
0.236407071352005,
0.23651768267154694,
-0.5974015593528748,
-0.341945081949234,
-0.7218203544616699,
-0.5122823119163513,
0.6388911008834839,
-0.359208881855011,
-0.13688042759895325,... | |
_cardMenu.add(new JMenuItem("Status"));
_mainButton.setComponentPopupMenu(_cardMenu); //Important, apparently!
}
```
So, lesson learned. Thanks for the help guys!
OK, I figured it out.
The problem was that the development database was not being migrated to the test database, even when running rake db:migrate, r... | [
0.17239300906658173,
-0.29091477394104004,
0.36254316568374634,
0.22225356101989746,
0.05970202758908272,
0.13822606205940247,
0.09026668220758438,
-0.3372657895088196,
-0.14621566236019135,
-0.7856235504150391,
-0.022090371698141098,
0.6341989040374756,
-0.1206902340054512,
0.100919194519... | |
Here is my problem : I have a pageadapter with 3 views, the left one is used to localize the user and fill in somes editText fields with the different elements of the address that was localized, here is the method :
```
private boolean getAddressLocation(Location location) {
if (location != null) {
lat = loc... | [
-0.37187379598617554,
-0.11078134924173355,
0.7478402853012085,
-0.2311948984861374,
0.26236867904663086,
0.14293666183948517,
0.1930123269557953,
0.06753319501876831,
-0.16141878068447113,
-0.7983178496360779,
-0.31737086176872253,
0.24262768030166626,
-0.36913537979125977,
0.353429108858... | |
Address address = (Address) addresses.get(0);
streetNumber = address.getAddressLine(0);
locality = address.getLocality();
postcode = address.getPostalCode();
country = address.getCountryName();
etCountry.setText(country, TextView.BufferType.EDITABLE);
etPostcode.se... | [
0.000003162951088597765,
-0.17436616122722626,
0.5143605470657349,
-0.1313694715499878,
0.17306429147720337,
0.25007322430610657,
0.43662869930267334,
-0.42746713757514954,
-0.028582148253917694,
-0.7876509428024292,
-0.6752735376358032,
0.0889110267162323,
-0.4753110706806183,
0.109024494... | |
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
```
The problem is that I d like the user to be able to edit the editText if the localization wasn't precise enough BUT when I edit those fields and that i come back to my main activity (the location one was the one on t... | [
0.000993573572486639,
-0.056384094059467316,
0.5277523994445801,
-0.1281490921974182,
0.028882617130875587,
-0.2566222548484802,
0.28563183546066284,
0.029883990064263344,
-0.13865013420581818,
-0.6747690439224243,
-0.023208610713481903,
0.3615226447582245,
-0.44706687331199646,
0.08055686... | |
my SQLite database... Everything works fine but when i modify the eedditText fields of the address that were automaticaly filled in with some setText from the address location the values that are stored in my database are still the automatically filled in fields of my editText ...
```
...
etCountry = (EditText) fi... | [
0.0005523823783732951,
0.14457079768180847,
0.7281889319419861,
-0.1242438331246376,
0.020219067111611366,
0.03594600781798363,
0.3697403073310852,
-0.2599017322063446,
0.08072464913129807,
-0.8404146432876587,
0.13805514574050903,
0.6823657751083374,
-0.3188225030899048,
0.098448902368545... | |
+ "," + etCountry.getText();
...
```
I don t understand ? Does it mean that onces the editText is filled with a .setText("...") we can't modifie it anymore ?
To verify: you seem to be implying that your string "display" is showing the old data. Is that the case?
Are you looking in the correct page of your PagerAdapt... | [
0.35795655846595764,
0.11270748823881149,
0.36518189311027527,
0.01451844908297062,
-0.09989820420742035,
-0.3369544744491577,
0.2674098312854767,
-0.2807904779911041,
-0.12960544228553772,
-0.6690390706062317,
-0.28183361887931824,
0.531326413154602,
-0.2699415981769562,
0.374207794666290... | |
I am loading an Assembly using `Assembly.LoadFrom()` as the assemblies are located in a different path from Application Base directory.
```
Dim oAssembly As Assembly = _
Assembly.LoadFrom("C:\\MyFolder\\" + ddlXlate.SelectedItem.ToString() + ".dll")
```
And I consume a `Type` from that assembly without any problem:
... | [
0.07477710396051407,
0.15729011595249176,
0.4886344373226166,
-0.3843238651752472,
0.22298158705234528,
0.007433032616972923,
0.30074024200439453,
-0.08082916587591171,
-0.10245406627655029,
-0.619678258895874,
-0.26723867654800415,
0.5687439441680908,
-0.5292545557022095,
0.24864102900028... | |
_
AddressOf MyResolveEventHandler
```
**Event Handler Method:**
```
Private Shared Function MyResolveEventHandler(ByVal sender As Object, _
ByVal args As ResolveEventArgs) As Assembly
Return Assembly.LoadFrom("C:\\PSIOBJ\\" + args.Name + ".dll")
End Function
```
And I thought maybe the error occurs because... | [
-0.22462110221385956,
0.22702257335186005,
0.4175441563129425,
-0.2655077278614044,
0.26051437854766846,
0.01805230975151062,
0.309504896402359,
-0.019290538504719734,
-0.21621519327163696,
-0.5680686831474304,
-0.11563136428594589,
0.43539875745773315,
-0.46239620447158813,
0.510622859001... | |
and they were working fine without the `AssemblyResolve` event. I was able to reach types in dynamically loaded `Assembly` from every where within the same `AppDomain`.
`LoadFrom()` can find dependencies automatically within the same requested assembly path and that couldn't be problem as everything this `dll` needs w... | [
0.0026801936328411102,
0.0698363333940506,
0.3258228302001953,
-0.2502928078174591,
-0.06905706971883774,
-0.11122957617044449,
0.5198853015899658,
-0.16637998819351196,
-0.25826215744018555,
-0.6375673413276672,
0.010255827568471432,
0.8504863381385803,
-0.6280062198638916,
0.205980241298... | |
assembly?
2. Doesn't it load the assembly where I can reach it everywhere (same AppDomain) using simple `Type.GetType(...)` method?
Can some one please fill the missed points and answer my questions?
You can use C#, in fact I don't like VB.NET but I have to use it here in Office.
If I understand your question correct... | [
0.11205603927373886,
0.022748785093426704,
0.30398300290107727,
-0.17719781398773193,
0.02961108274757862,
-0.09479641169309616,
0.5512192845344543,
-0.34465059638023376,
-0.2735033929347992,
-0.5870992541313171,
-0.16616076231002808,
0.39077305793762207,
-0.6701844930648804,
0.09550725668... | |
the variable `type` will always be `null`.
Cause
=====
What you encounter is the problem of [different loading contexts for assemblies in .NET](http://msdn.microsoft.com/en-us/library/dd153782.aspx). There are generally three, actually four types of loading contexts, in short:
* The default load context. This is use... | [
0.13238151371479034,
-0.09463566541671753,
0.3520258665084839,
0.019237123429775238,
-0.18667249381542206,
0.2444455474615097,
0.06839454919099808,
-0.15279747545719147,
-0.23930883407592773,
-0.3099615275859833,
-0.14842315018177032,
0.5065357685089111,
-0.5125375390052795,
0.199634566903... | |
The no-context context. When you load an assembly using any of [`Assembly.Load(byte\[\],..)`](http://msdn.microsoft.com/en-us/library/h538bck7.aspx) and [`Assembly.LoadFile`](http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfile.aspx) methods, or when you load a dynamic assembly not saved to disk,... | [
0.07663524895906448,
-0.10934434831142426,
0.30034372210502625,
0.05524788796901703,
-0.14158914983272552,
-0.1782173067331314,
0.2900215983390808,
0.17274408042430878,
-0.2605978846549988,
-0.29318639636039734,
-0.2707917392253876,
0.6497252583503723,
-0.5682228803634644,
0.14852012693881... | |
moved it, things started to fall apart.
**More specifically:**
When you call `Type.GetType(string)`, it will query all statically *referenced* assemblies in the path and dynamically loaded assemblies in the current path (`AppDomain.BaseDirectory`), the GAC and in `AppDomain.RelativeSearchPath` and. Unfortunately, t... | [
0.00982461404055357,
-0.22090056538581848,
0.7242537140846252,
-0.23784248530864716,
-0.056323181837797165,
-0.055665042251348495,
0.17347602546215057,
-0.20837728679180145,
-0.2662966251373291,
-0.6983036994934082,
0.06250045448541641,
0.22820405662059784,
-0.5584258437156677,
0.198219850... | |
found, returns null without trying anything else (or throws `FileNotFoundException`, which can be rather confusing).
You can test this for yourself: `Assembly.Load` will not work when you just supply the assembly name to it.
Solutions
=========
There are several solutions. One you already named yourself and that's k... | [
0.20974215865135193,
-0.1990603357553482,
0.042697977274656296,
-0.005094289779663086,
0.18617300689220428,
0.055058278143405914,
0.08786135911941528,
-0.28537842631340027,
-0.1260710507631302,
-0.5355607271194458,
-0.07737475633621216,
0.49419721961021423,
-0.44622573256492615,
0.14880621... | |
`sAssemblyName`, but isn't that also something you need floating around?).
2. Use a generic resolver that checks the loaded assemblies and returns the loaded assembly. You don't need to call `LoadFrom` again. I tested the following and that works splendidly and quite fast:
```
// works for any loaded assembly, regardl... | [
-0.3892739415168762,
-0.18630768358707428,
0.4883098304271698,
-0.33078399300575256,
0.14885355532169342,
-0.18887975811958313,
0.4797658622264862,
-0.28286388516426086,
-0.25761878490448,
-0.6766800284385681,
-0.238031268119812,
0.543257474899292,
-0.2750425934791565,
0.14857132732868195,... | |
select a).First();
return asm;
}
// set it as follows somewhere in the beginning of your program:
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
```
3. Use the AppDomain.CurrentDomain.AssemblyLoad and .AssemblyResolve events together. The first you use to memorize each loaded assembly ... | [
-0.18389827013015747,
-0.18388091027736664,
0.4376718997955322,
-0.3436947464942932,
0.22433096170425415,
0.10031837224960327,
0.4144114851951599,
-0.273002028465271,
-0.18335741758346558,
-0.6896767616271973,
-0.223083034157753,
0.5122823715209961,
-0.4599185585975647,
0.2124883383512497,... | |
it'll work in your scenario.: this doesn't work. GetType *first* tries to load the assembly, when that fails, it doesn't try to resolve the type and this event never fires.
5. Add the libraries you want to resolve to the GAC or to any (relative) path of your application. This is by far the easiest solution.
6. Add the ... | [
0.04969170689582825,
-0.08354464918375015,
0.4193755090236664,
0.03397892415523529,
0.1476762741804123,
-0.042222920805215836,
0.33290597796440125,
-0.3566388487815857,
-0.08130292594432831,
-0.8607059121131897,
-0.17977379262447357,
0.5449146032333374,
-0.5603169798851013,
-0.280732005834... | |
when it comes to loaded assemblies at first look. Once you understand the ideas behind the several contexts, try to place the assembly in the default context. When that is not possible, you can create an `AssemblyResolve` event handler, which isn't that hard to make generically applicable. | [
0.21831057965755463,
-0.2769570052623749,
-0.34052911400794983,
0.05972645804286003,
-0.13879244029521942,
-0.2321063131093979,
0.061170194298028946,
0.06591465324163437,
-0.3092992901802063,
-0.43779340386390686,
-0.13557536900043488,
0.572636067867279,
-0.46353021264076233,
-0.2012709528... | |
I would like to create a program that will run in background as a final product. For debug purpose I want it to display a console.
I learned that there is a **ShowWindow( hWnd, SW\_HIDE );** function, but if I use it in a 'standard' main function the console window still pops up for a moment. I was trying to work it o... | [
0.5309122800827026,
0.3032960593700409,
0.2563730776309967,
-0.043454889208078384,
0.22714515030384064,
-0.09888701885938644,
0.36372995376586914,
-0.11051339656114578,
-0.19849486649036407,
-0.5994823575019836,
-0.182786226272583,
0.29026728868484497,
-0.5815734267234802,
0.22929103672504... | |
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
while(1);
return 0;
}
#else
#pragma comment(linker, "/SUBSYSTEM:CONSOLE")
int main(int argc, int **argv)
{ | [
-0.08685927838087082,
-0.25008541345596313,
0.6871628165245056,
-0.10048196464776993,
0.16977070271968842,
-0.035820722579956055,
0.31981420516967773,
-0.19519442319869995,
-0.04600486531853676,
-0.3952411413192749,
-0.4308988153934479,
0.45265257358551025,
-0.4577082395553589,
0.525934696... | |
HWND hWnd = GetConsoleWindow();
while(1);
return 0;
}
#endif
```
Here I managed to prevent the window form popping up, but I can't pass parameters to the program.
I believe there is a much better solution for this. Can you share?
PS
I don't want to use .NET.
This is an answer to the first par... | [
0.3961525559425354,
0.10010213404893875,
0.40465298295021057,
-0.07262295484542847,
-0.0903916284441948,
-0.358381450176239,
0.423318088054657,
-0.1436499059200287,
-0.10699968785047531,
-0.9096400141716003,
-0.30977997183799744,
0.5521141290664673,
-0.4095490276813507,
0.07118897885084152... | |
the second part of the question, about command line arguments, separately.
```
// How to create a Windows GUI or console subsystem app with a standard `main`.
#ifndef _MSC_VER
# error Hey, this is Visual C++ specific source code!
#endif
// Better set this in the project settings, so that it's more easily configure... | [
-0.30491650104522705,
0.13686661422252655,
0.5898526906967163,
-0.18139800429344177,
-0.06031187251210213,
0.2136186808347702,
0.13288751244544983,
-0.2102607786655426,
-0.24902889132499695,
-0.5564167499542236,
-0.5047764778137207,
0.4650196135044098,
-0.48317161202430725,
-0.173811867833... | |
of standard `assert`, so it’s not required to be globally meaningful. However, in practice it is globally meaningful. And then it provides a bit of portability compared to using a Visual C++ macro such as `DEBUG`.
Anyway, in order to make it easier to configure the subsystem, unless you want to *enforce* that debug bu... | [
0.28036925196647644,
-0.028876474127173424,
-0.039747294038534164,
0.08412396907806396,
-0.42791396379470825,
-0.4427501857280731,
0.25843843817710876,
-0.08456511050462723,
0.019784538075327873,
-0.4709550738334656,
-0.20496223866939545,
0.9055395126342773,
-0.0326954647898674,
0.02794249... | |
can check the subsystem programmatically instead of just by inspection (i.e. instead of noting whether the above program produces a console or not):
```
// How to create a Windows GUI or console subsystem app with a standard `main`.
#ifndef _MSC_VER
# error Hey, this is Visual C++ specific source code!
#endif
// B... | [
-0.10688013583421707,
0.05449541285634041,
0.474010705947876,
0.039781488478183746,
0.0009376953821629286,
-0.2132534235715866,
0.10200522840023041,
-0.35577723383903503,
-0.21410627663135529,
-0.5103700160980225,
-0.5353966355323792,
0.34365856647491455,
-0.21200670301914215,
-0.009407742... | |
<string> // std::wstring
#include <sstream> // std::wostringstream
using namespace std;
template< class Type >
wstring stringFrom( Type const& v )
{
wostringstream stream;
stream << v;
return stream.str();
}
class S
{
private:
wstring s_;
public:
template< class Type >
... | [
-0.06773535907268524,
-0.569869339466095,
0.8983599543571472,
-0.43573278188705444,
-0.0038838055916130543,
0.24541710317134857,
0.528228223323822,
-0.4914347529411316,
-0.10487716645002365,
-0.5988839864730835,
-0.4345552921295166,
0.6891757845878601,
-0.3608158826828003,
-0.0476015470921... | |
return *this;
}
operator wstring const& () const { return s_; }
operator wchar_t const* () const { return s_.c_str(); }
};
IMAGE_NT_HEADERS const& imageHeaderRef()
{
HMODULE const hInstance =
GetModuleHandle( nullptr );
IMAGE_DOS_HEADER const* const pImageHeader =... | [
0.18851731717586517,
-0.42052415013313293,
0.7412934899330139,
-0.11615701019763947,
0.13464006781578064,
0.1508362740278244,
0.5665571093559265,
-0.5655617117881775,
-0.12172674387693405,
-0.58817058801651,
-0.23880723118782043,
0.6601091027259827,
-0.34265533089637756,
0.2524433135986328... | |
pImageHeader->e_magic == IMAGE_DOS_SIGNATURE ); // "MZ"
IMAGE_NT_HEADERS const* const pNTHeaders = reinterpret_cast<IMAGE_NT_HEADERS const*>(
reinterpret_cast< char const* >( pImageHeader ) + pImageHeader->e_lfanew
);
assert( pNTHeaders->OptionalHeader.Magic == IMAGE_NT_OPTIO... | [
-0.009778542444109917,
-0.29797953367233276,
0.6091560125350952,
-0.005507995840162039,
0.0784091055393219,
0.3410751223564148,
0.45429787039756775,
-0.5500927567481995,
0.2819797992706299,
-0.8029449582099915,
-0.34226012229919434,
0.7131152153015137,
-0.13178102672100067,
-0.023146167397... | |
subsystem = imageHeader.OptionalHeader.Subsystem;
MessageBox(
0,
S() << L"Subsystem " << subsystem << L" "
<< (0?0
: subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI? L"GUI"
: subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI? L"Console" | [
-0.6499823331832886,
-0.3713008165359497,
0.5933363437652588,
0.029433725401759148,
0.061983462423086166,
0.08275739848613739,
-0.1239994689822197,
0.1329422891139984,
-0.06868816167116165,
-0.7857855558395386,
-0.4757250249385834,
0.43758732080459595,
-0.3017466366291046,
0.04933930188417... | |
: L"Other"),
L"Subsystem info:",
MB_SETFOREGROUND );
}
``` | [
-0.21446551382541656,
0.08585948497056961,
0.36502018570899963,
-0.3820618689060211,
0.4732134938240051,
0.11251623928546906,
-0.00207946402952075,
-0.04440729692578316,
-0.1628873646259308,
-0.3746972382068634,
-0.6994522213935852,
0.8234379291534424,
-0.6928160190582275,
0.22088561952114... | |
can u please tell me how to write regular expression to match all time formats such as given below
```
2-sec,
0-second,
1-min,
1 mins,
4 minutes
5-minute
re=re.sub('[0-9].[{minutes|mins|sec|second|seconds|minute}]','TIME443"',"1 mins is value is 4 minutes value 5-minute")
```
there is some mistake in my re pleaese... | [
-0.31716153025627136,
0.08238101005554199,
0.6649342179298401,
0.06456704437732697,
0.04803932458162308,
0.3369291126728058,
0.48939406871795654,
-0.19058844447135925,
0.16441723704338074,
-0.6567659378051758,
-0.33470743894577026,
0.6003350615501404,
0.051630206406116486,
-0.0416070558130... | |
How can I get a list of all the selected values for a field?
For example I have a field called countries, and I want to get all countries selected for a certain node.
I need to have this list, because I want the region to be automatically selected in another field (regions), according to the chosen country.
Ex: I ... | [
-0.2603130638599396,
-0.22155702114105225,
0.2727043330669403,
0.29490727186203003,
0.4223683774471283,
0.2581325173377991,
-0.23857912421226501,
0.13954435288906097,
-0.4099479615688324,
-0.7179022431373596,
-0.3220668435096741,
-0.00782828964293003,
-0.2068215310573578,
0.173214346170425... | |
the countries field :
Country: France
Regions: France
***Edit:***
I tried with the function:[field\_get\_items()](http://api.drupal.org/api/drupal/modules!field!field.module/function/field_get_items/7), but all I get is an array:
```
$items = field_get_items('node', $node, 'field_countries', $node->language);
```
... | [
-0.011142167262732983,
-0.02087634988129139,
0.6859303712844849,
0.06402494758367538,
0.26073676347732544,
0.25753363966941833,
0.09403135627508163,
0.31253156065940857,
-0.5654985904693604,
-0.26614123582839966,
-0.3648776412010193,
-0.17025615274906158,
-0.2047801911830902,
0.27423465251... | |
I'm using a control template to show validation errors on each of my controls using the built-in WPF's validation mechanism, and everything works fine. The controlTemplate looks like this:
```
<ControlTemplate x:Key="MyErrorTemplate" TargetType="{x:Type Control}">
<StackPanel Orientation="Horizontal">
<Bor... | [
-0.2582377791404724,
-0.05217273533344269,
1.208065152168274,
0.23133233189582825,
-0.09892681986093521,
-0.059199023991823196,
0.039531365036964417,
-0.6370109915733337,
-0.13704462349414825,
-0.6100272536277771,
0.25505539774894714,
0.5331315398216248,
0.040576204657554626,
0.01597671955... | |
ToolTip="{Binding ElementName=MyAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
</StackPanel>
</ControlTemplate>
```
I have read that the validation mechanism wraps the validated control up with the control template (the default one or a custom one like above) whenever the control gets an err... | [
0.095836341381073,
-0.20935827493667603,
0.7340980768203735,
0.07087867707014084,
-0.0713118389248848,
0.058377597481012344,
0.21686303615570068,
-0.9364446401596069,
0.044700250029563904,
-0.37717491388320923,
-0.10877572000026703,
0.3121926188468933,
-0.25929322838783264,
0.0056163212284... | |
is exactly above the control and that let us
> easily place the control template content relative to the original
> control" ([see more](http://www.nbdtech.com/Blog/archive/2010/07/05/wpf-adorners-part-3-ndash-adorners-and-validation.aspx))
**How can I perform this same behavior for another functionality? I mean use... | [
0.320101261138916,
0.02375352941453457,
0.3845275938510895,
0.14289644360542297,
-0.12003608047962189,
-0.0752827450633049,
0.2571697533130646,
-0.7313246726989746,
-0.09541626274585724,
-0.39460769295692444,
0.14301668107509613,
0.39854639768600464,
-0.3287528157234192,
0.1521737724542617... | |
hook up to the `HasCustomError_Changed` to enable showing/hiding of your adorner
4. create/copy the TemplatedAdorner Class that is then showing your Template
I recommend you use [.NET Reflector](http://www.reflector.net/) or [ILSpy](http://wiki.sharpdevelop.net/ILSpy.ashx) to look at the following code to get some und... | [
0.39645329117774963,
-0.05604727193713188,
0.45384564995765686,
-0.12682406604290009,
-0.32557860016822815,
-0.2347789704799652,
0.36256837844848633,
-0.3146749436855316,
0.012997825630009174,
-0.7381539940834045,
0.3293868899345398,
0.6293195486068726,
-0.32152771949768066,
0.014061544090... | |
I have this code in a **.html.erb** file:
```
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script>
FB.Event.subscribe('edge.create',
function(response) {
send_fb_like();
}
);
FB.Event.subscribe('edge.remove',
function(response) {
send_fb_unlike()... | [
0.27240103483200073,
-0.18469862639904022,
0.9636063575744629,
-0.2545774579048157,
-0.2302858829498291,
0.24013465642929077,
0.3380821943283081,
-0.3193304240703583,
0.1297314614057541,
-0.7280188798904419,
0.15050265192985535,
0.30514317750930786,
-0.26313355565071106,
0.4033266901969909... | |
alert("You unliked"+consumer_name);
}
</script>
```
This is working correctly, and I can access the **@consumer.name** correctly. However, if I change this to:
Where facebook\_consumer.js looks like this:
```
$(function(){
FB.Event.subscribe('edge.create',
function(response) {
send_fb_li... | [
0.27513355016708374,
-0.40778639912605286,
0.6371289491653442,
-0.3711562752723694,
-0.14140798151493073,
0.11686866730451584,
0.5198696851730347,
-0.12064801901578903,
-0.07849429547786713,
-0.6729217767715454,
0.09857211261987686,
0.7188187837600708,
-0.3152354657649994,
0.14650095999240... | |
}
);
function send_fb_like()
{
var business_name = '<%= @consumer.name %>';
alert("You liked"+consumer_name);
}
function send_fb_unlike()
{
var business_name = '<%= @consumer.name %>';
alert("You unliked"+consumer_name);
}
});
```
It will dump... | [
0.01725408062338829,
-0.23660998046398163,
0.9874572157859802,
-0.216138556599617,
0.04406663775444031,
0.29046812653541565,
0.44526156783103943,
-0.03368567302823067,
0.035686202347278595,
-0.18415437638759613,
-0.13143938779830933,
0.9090257287025452,
-0.30971142649650574,
0.406646490097... | |
@consumer.name %>`. I have tried saving the file as js.erb, but then it seems it doesn't know what @consumer is.
Any thoughts on what is the best approach?
Your best bet is probably to create an app-wide JS object to store values you need. At the top of the page, you can add elements to this object, and they will be a... | [
0.2553856074810028,
0.10997064411640167,
0.5610295534133911,
-0.27263057231903076,
-0.15658007562160492,
0.3920043706893921,
0.0443551279604435,
-0.2950061857700348,
-0.07310766726732254,
-0.6807847619056702,
0.004141777753829956,
0.8850038051605225,
-0.3797962963581085,
-0.034941218793392... | |
I'm extremely new to Flash, and I'm using CS5.
I have a button with animations on scroll-over. How can I 'duplicate' this button, as I want several more buttons with the same template, just different text (and different functions called)?
Sorry for the foolish question, but the Duplicate button is frustrating, as wh... | [
0.36937785148620605,
0.16154973208904266,
0.1429865062236786,
0.06665748357772827,
0.005897091701626778,
0.02514730952680111,
0.08250056952238083,
0.15309320390224457,
-0.49581483006477356,
-0.7409119009971619,
0.3492697477340698,
0.2324322611093521,
-0.2778182625770569,
0.3378317058086395... | |
EDIT: SOLUTION/WORKAROUND
I've found a workaround.
Simply make your first button, then in the Library duplicate it. Edit the new button from the library panel, then you can click and drag the new button onto the stage.
-Would've made a real answer, but this account doesn't have the reputation.
Your best bet is pro... | [
0.0776112750172615,
-0.04075174033641815,
0.5964804887771606,
0.04246785119175911,
0.3196925222873688,
0.27714940905570984,
0.33977755904197693,
-0.35976800322532654,
-0.14333896338939667,
-0.8404755592346191,
-0.12413013726472855,
0.5811383724212646,
-0.4969932734966278,
-0.09381897002458... | |
@variable1 %>";
app.keyName2 = "<%= @variable2 %>";
</script>
``` | [
-0.04749719426035881,
-0.09505628794431686,
0.5229262709617615,
-0.314715176820755,
0.18512260913848877,
0.1479337364435196,
0.1873527467250824,
0.044169433414936066,
0.19010844826698303,
-0.21117591857910156,
-0.3756583631038666,
0.6780915856361389,
-0.49727556109428406,
0.080243416130542... | |
I'm trying to send a midi signal from my c# app to a track in Ableton Live.
I've tried both the Bass.net and midi-dot-net both with the same effect: No events arriving in Ableton. (I've got loopMidi installed and thats where I send my signals to.)
Strangely enough when I target my midi-keyboard it plays the stanard ... | [
0.1728161871433258,
-0.3268510401248932,
0.8052018284797668,
-0.24619948863983154,
-0.08492571860551834,
0.1739821583032608,
0.29649004340171814,
-0.14310161769390106,
-0.0387306846678257,
-0.7799755334854126,
0.11494982987642288,
0.6993024945259094,
-0.22285111248493195,
0.075148455798625... | |
still misunderstanding some basics here..
Can anybody see what I'm doing wrong?
I would advise using a utility such as MidiOx to see that MIDI signals are actually being sent as you suspect they are.
If that is working as expected, then you probably haven't configured Live's MIDI I/O correctly in the preferences. A n... | [
0.6905941963195801,
-0.05946001410484314,
0.16811370849609375,
0.14309190213680267,
-0.1556210070848465,
-0.37374386191368103,
0.2560462951660156,
0.16309118270874023,
-0.2951522171497345,
-0.6243532299995422,
0.17293302714824677,
0.9195439219474792,
-0.14924214780330658,
0.005457451567053... | |
Is there a better way to do something like this? This is fine but I'd think there's probably a shortcut to get the same results. I guess to add more arrays easily I could just turn it into a function and have the for loop outside it but still.
Just wondering.
```
<?
$array1 = array("test1","test2","test3","test4");
$... | [
0.48570936918258667,
-0.1663666069507599,
-0.04205255210399628,
-0.26178884506225586,
-0.24295566976070404,
0.16725926101207733,
0.5692933201789856,
-0.6182975769042969,
-0.09288880228996277,
-0.35801076889038086,
0.026032553985714912,
0.6134159564971924,
-0.4366719722747803,
-0.1669085621... | |
TO VALUE => KEY SO THAT THE KEYS CAN BE GET. REMEMBER TO SWITCH IT BACK.
$array2 = array_flip($array2);
$key1 = $array1[$val1]; //NOW MUST ITERATE THROUGH USING VALUES ABOVE BECAUSE THE KEYS ARE NO LONGER NUMBERS.
$key2 = $array2[$val2];
$array1 = array_flip($array1); //SWITCHING IT BACK.
$array2 ... | [
0.1286916732788086,
-0.3273390531539917,
0.4094831645488739,
-0.41447433829307556,
0.21492402255535126,
0.04056737944483757,
0.305111825466156,
-0.6740022897720337,
-0.46212807297706604,
-0.2458600103855133,
-0.1477113515138626,
0.6297138929367065,
-0.4216392934322357,
0.10643316805362701,... | |
for Insert and Delete. NotifyPropertyChanged is for update of an items. In the posted code you don't actually implement INotifyPropertyChanged.
```
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
... | [
0.001099070068448782,
-0.3037005364894867,
0.5179470181465149,
0.0314546599984169,
0.28988462686538696,
-0.21885381639003754,
0.3342406749725342,
-0.22589102387428284,
-0.32254672050476074,
-0.4906577467918396,
-0.3240487277507782,
0.784666121006012,
-0.3621158003807068,
0.2053316682577133... | |
TwoWay answer of celopez3 | [
-0.41312941908836365,
-0.0205441415309906,
0.3184816837310791,
-0.016901034861803055,
-0.2170654982328415,
0.3537260591983795,
0.11712342500686646,
-0.1994515210390091,
-0.1507914960384369,
-0.8991109728813171,
-0.1727651059627533,
0.23135222494602203,
-0.04781453683972359,
0.0966911688446... | |
I am using igraph to do some network analysis. As part of that, I have to create a matrix with 2 columns and as many rows as there are links. I have a large network (several million links) and creating this matrix didn't work after 3 hours of run time (no errors, just no result, and it shows "not responding").
What is... | [
-0.01864188350737095,
0.14818882942199707,
0.35217875242233276,
-0.0656566396355629,
0.024132439866662025,
0.21235905587673187,
0.6485971212387085,
-0.12370627373456955,
-0.2220120131969452,
-0.9316732287406921,
0.10752929002046585,
0.5882756114006042,
-0.19152073562145233,
0.0474911369383... | |
This made me positive it wasn't the size of the matrix; it turned out to be an error in which columns of another matrix I was using to create that matrix.
The theoretical limit of a vector in R is 2147483647 elements. So that's about 1 billion rows / 2 columns.
...but that amount of data does not fit in 4 GB of memory... | [
-0.14838066697120667,
0.2135475128889084,
0.4973660409450531,
-0.1841648817062378,
0.08216722309589386,
0.4848078191280365,
0.2029118835926056,
-0.6922924518585205,
-0.40732353925704956,
-0.38646844029426575,
0.2475835233926773,
0.3740285336971283,
-0.0921425074338913,
0.12410122156143188,... | |
one instance of each unique string though).
So what typically happens is that the machine starts using virtual memory and start swapping. Heavy swapping typically kills all hope of ever finishing in this century - especially on Windows.
But if you are using a package (igraph?) and you're asking it to produce the matr... | [
0.22798162698745728,
-0.12656433880329132,
0.09065110981464386,
0.4735153615474701,
0.10652907937765121,
-0.08298633992671967,
0.06058735400438309,
0.06842796504497528,
-0.286687970161438,
-0.7007673978805542,
0.013521864078938961,
0.1200610026717186,
-0.30817240476608276,
0.20343315601348... | |
time, which would again kill all hope of ever finishing in this century...
A good way to investigate could be to time it on a small graph (e.g. using `system.time`), and the again when doubling the graph size a couple of times. Then you can see if the time is linear or quadratic and you can estimate how long it will t... | [
0.14642910659313202,
-0.37186193466186523,
0.6323369145393372,
0.35715144872665405,
0.22158390283584595,
0.2127339094877243,
0.23178967833518982,
0.10644928365945816,
-0.8874415755271912,
-0.874902606010437,
0.40375399589538574,
-0.04186774790287018,
-0.20311489701271057,
0.674284219741821... | |
I have a serializable `Message` class that has a `Data As Object` property that I'm using as a generic holder for information to be sent via a system that uses a combination of push technology and/or IPC to communicate with any other programs that are interested in the information. This allows the communication piece t... | [
0.4312968850135803,
0.21892806887626648,
0.09452174603939056,
0.21195092797279358,
-0.03901021555066109,
0.013835512101650238,
-0.06733779609203339,
0.011890354566276073,
-0.3509717881679535,
-0.31345897912979126,
-0.032078132033348083,
0.38500064611434937,
-0.3158665895462036,
0.591604769... | |
unable to find the assembly for the types stored within my `Data As Object` property, because I'm deserializing in the assembly that contains the `Message` class... not the assembly that contains the type that `Data As Object` originally was. The assembly that contains the description of the information being transmitt... | [
0.06926597654819489,
0.059133898466825485,
0.4188636243343353,
0.041988879442214966,
-0.09799560904502869,
0.13447348773479462,
0.3490959107875824,
0.07172266393899918,
-0.19502024352550507,
-0.625023365020752,
-0.031398672610521317,
0.3890319764614105,
-0.5096077919006348,
0.6474686264991... | |
other end. Perhaps it's not possible to pass a type as an `Object` via another assembly without it knowing about my type?
There's a good chance I'm approaching the problem entirely the wrong way. Alternatives gladly accepted. Thanks!
> Q: Do serialized objects lose their types?
A: No
> Q: If I cast an object to "obj... | [
-0.12510499358177185,
-0.15516187250614166,
0.4340154528617859,
0.21232573688030243,
-0.36945438385009766,
0.2478300929069519,
0.2864964008331299,
-0.07128457725048065,
-0.07204355299472809,
-0.6768267750740051,
0.22458727657794952,
0.4957030117511749,
-0.3400735557079315,
0.10532966256141... | |
I'm a bit confused over jQuery terminology for what I'm trying to accomplish.
Essentially I have a jQuery plugin that takes around 5 seconds from instantiation to being usable. I want to expose an onReady event so the user can take action (like making a button visible) when the plugin is ready.
Something as simple a... | [
0.39306822419166565,
-0.11808973550796509,
0.19431202113628387,
-0.0991668701171875,
0.10249092429876328,
-0.35370203852653503,
0.39099687337875366,
-0.11229248344898224,
0.1254834532737732,
-0.557668149471283,
-0.06211244687438011,
0.644713819026947,
-0.11281883716583252,
-0.1452432572841... | |
internally triggers its 'onReady' event.
Thanks for your help!
In order to refer to a local variable inside of a callback (the onClick() method) that variable has to be declared "final" so that the compiler knows that the reference to it won't change.
You can work around this easily by making punkte a class-level fie... | [
0.2581157982349396,
-0.24803289771080017,
0.6585869193077087,
-0.1478121280670166,
0.11838008463382721,
0.08786608278751373,
0.4185923635959625,
-0.5295366048812866,
-0.26940104365348816,
-0.5587469935417175,
-0.2749585509300232,
0.6825474500656128,
-0.08493179827928543,
-0.086636818945407... | |
punkte=punkte+1;
};
});
}
``` | [
0.14939650893211365,
-0.39571109414100647,
0.2666373550891876,
-0.3527464270591736,
0.03201555460691452,
-0.056344687938690186,
0.39904025197029114,
-0.23514841496944427,
-0.05818495899438858,
-0.35975396633148193,
-0.211835116147995,
0.6299296021461487,
-0.351319819688797,
-0.019733371213... | |
I am new to cherrypy and am trying to mount a simple hello world application but it keeps returning "NotFound: (404, "The path '/' was not found.")", but I have defined it.
Here's what I got,
In the **\_\_*init*\_\_**.py
```
import cherrypy
from HomeNetMain import HomeNetMain
cherrypy.config.update("global.cfg")
#I... | [
-0.11922287195920944,
0.28868746757507324,
0.3204379677772522,
-0.174240380525589,
0.15964266657829285,
0.05563918501138687,
0.2514824867248535,
0.11829963326454163,
-0.1238977313041687,
-0.7057790756225586,
0.0913671925663948,
0.7031041979789734,
-0.2142648547887802,
0.2018572986125946,
... | |
or index.exposed)
global.cfg
```
[global]
server.socket_host: "127.0.0.1"
server.socket_port: 9080
log.screen: True
log.error_file: "/tmp/cherrypy.error"
log.access_file: "/tmp/cherrypy.access"
```
main.cfg
```
[/]
log.screen: True
log.error_file: "/tmp/homenet.error"
log.access_file: "/tmp/homenet.access"
```
I... | [
-0.22594326734542847,
0.2605462372303009,
0.3815966248512268,
-0.20912836492061615,
-0.07779643684625626,
0.3287311792373657,
0.48595213890075684,
-0.22584833204746246,
-0.4346955120563507,
-0.6434974074363708,
0.1178445816040039,
0.747691810131073,
-0.27259284257888794,
-0.077893696725368... | |
I have two arrays. If a user adds a product, we put it in the ProductArray. If they remove that product, we add it to the ProductArrayRemove array as well as remove it from the product array. (We need to know products that have been added as well as products that have been removed. This requires redundancy.)
```
Produ... | [
-0.15615496039390564,
-0.2641788721084595,
0.607903242111206,
-0.5633285641670227,
-0.1328994482755661,
0.3454034924507141,
0.16912496089935303,
-0.5802105069160461,
-0.053414277732372284,
-0.5676708817481995,
-0.16645467281341553,
0.46099260449409485,
-0.41475918889045715,
0.1807576417922... | |
if (ProductID == ItemID) {
ProductArray.splice(i,1);
break;
}
}
```
It seems that there should be a better way of accomplishing this task.
Is there a more efficient means of getting rid of a single item (that will always be an integer) from an array?
One different idea that would be super fast to... | [
0.0625469908118248,
-0.26172351837158203,
0.33346623182296753,
0.15942707657814026,
-0.007789392955601215,
-0.13008016347885132,
0.21795547008514404,
-0.41089630126953125,
-0.3673495948314667,
-0.5842560529708862,
-0.06778223067522049,
0.211061030626297,
-0.43448618054389954,
0.37522649765... | |
you do it set it's property `obj.removed = true`.
The add it back again, you just change the value of that property.
To iterate just the added items, you just skip the ones with the `.removed == true` property. To iterate just the removed items, you do just the reverse. Here would be a couple of iterators:
```
Produ... | [
0.26480984687805176,
-0.5947465300559998,
0.2169373631477356,
-0.20422008633613586,
0.11837218701839447,
0.056883104145526886,
0.08742037415504456,
-0.5051146149635315,
-0.07814350724220276,
-0.08740265667438507,
-0.267994225025177,
0.8074639439582825,
-0.41078025102615356,
-0.063474550843... | |
return;
}
}
}
}
ProductArray.iterateRemoved = function(fn) {
for (var i = 0; i < this.length; i++) {
if (this[i].removed) {
if (fn.call(this, i, this[i]) === false) {
return; | [
0.07320919632911682,
-0.6487780809402466,
0.47260814905166626,
-0.6275029182434082,
0.18555735051631927,
0.23351122438907623,
0.33933013677597046,
-0.6272331476211548,
0.4274125099182129,
-0.26924407482147217,
-0.20551879703998566,
0.6960766911506653,
-0.3863952159881592,
0.327282369136810... | |
}
}
}
}
ProductArray.getSubLength = function(removed) {
var cnt = 0;
for (var i = 0; i < this.length; i++) {
if (removed == this[i].removed) {
++cnt;
}
}
return(cnt);
}
```
And, you would use them like this:
```
ProductArray.iterateAdded(function(i, val) {
... | [
-0.05309855937957764,
-0.3597713112831116,
0.5358645915985107,
-0.3187216520309448,
0.14654956758022308,
0.24968601763248444,
-0.0630846619606018,
-0.4830441176891327,
-0.1904531866312027,
-0.3331376016139984,
-0.11204566806554794,
0.5187576413154602,
-0.5074429512023926,
0.383343398571014... | |
array
// i is the index we are iterating
// val is the array element we are iterating this[i]
// put code here
});
``` | [
-0.08932865411043167,
-0.04743506759405136,
0.26376259326934814,
-0.20592579245567322,
0.04185628890991211,
0.05055897682905197,
0.2242654412984848,
-0.4036964178085327,
0.12380384653806686,
-0.35213103890419006,
-0.17751377820968628,
0.690433919429779,
-0.31216904520988464,
-0.07168658077... | |
I am writing an erlang module that has to deal a bit with strings, not too much, however, I do some tcp recv and then some parsing over the data.
While matching data and manipulating strings, I am using binary module all the time like `binary:split(Data,<<":">>)` and basically using `<<"StringLiteral">>` all the time.... | [
0.3583974540233612,
-0.043146248906850815,
0.04838212952017784,
0.0009475479018874466,
-0.006922613829374313,
-0.3630913496017456,
0.027561340481042862,
0.19189994037151337,
-0.2870766520500183,
-0.5180299282073975,
0.11470755934715271,
0.42385777831077576,
-0.3870493471622467,
-0.19782288... | |
need to be very aware of how your string is encoded in your binaries. When you do <<"StringLiteral">> in your code, you have to be aware that this is simply a binary serialization of the list of code-points. Your Erlang compiler reads your code as ISO-8859-1 characters, so as long as you only use Latin-1 characters and... | [
0.054126787930727005,
0.1709330677986145,
0.41624999046325684,
0.049693506211042404,
0.06510289758443832,
-0.43238890171051025,
0.3115040957927704,
0.08687279373407364,
-0.3645288646221161,
-0.5668608546257019,
-0.2010747641324997,
0.4727347493171692,
-0.5638881921768188,
-0.31000977754592... | |
You might be surprised what you see on your UTF-8 encoded web applications if you use <<"StrïngLïteral">> in your code.
There was an EEP proposal for binary support in the form of <<"StrïngLïteral"/utf8>>, but I don't think this is finalized.
Also be aware that your binary:split/2 function may have unexpected results... | [
0.33437493443489075,
-0.23674800992012024,
-0.2403625249862671,
0.13920605182647705,
-0.10169432312250137,
-0.0576726570725441,
-0.06306164711713791,
0.01753445528447628,
-0.5008302927017212,
-0.5997171998023987,
-0.4187504053115845,
0.54362952709198,
-0.3541818857192993,
-0.03190086036920... | |
are no 32-bit characters.
The [unicode module](http://www.erlang.org/doc/man/unicode.html) should be use, but tread carefully when you use literals. | [
0.06456367671489716,
0.3188619315624237,
0.06923707574605942,
0.04925945773720741,
0.003727733390405774,
0.04699406400322914,
0.36130914092063904,
-0.18690815567970276,
-0.2675410211086273,
-0.39536404609680176,
-0.6056853532791138,
0.6495136618614197,
-0.3992558717727661,
-0.6336474418640... | |
I mae a WCF service that contain this method :
```
public List<LocationDB> GetLocation()
{
List<LocationDB> locations = null;
using (SqlConnection connection = new SqlConnection(conn))
{
using (SqlCommand command = new SqlCommand())
{
command.Connection = connection;
... | [
0.1234622672200203,
-0.16628892719745636,
0.6121214628219604,
-0.18946945667266846,
0.18999768793582916,
-0.1340859979391098,
-0.04068780317902565,
-0.19609606266021729,
-0.11116500943899155,
-0.657296359539032,
-0.23532012104988098,
0.37106063961982727,
-0.4710756540298462,
0.435274988412... | |
locations list..
```
my problem is when i want to bind the result from this method in my code i do the following.
```
void MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
client.GetLocationCompleted += new EventHandler<GetLocationCompletedEventArgs>(client_GetLocationCompleted);
... | [
-0.37423786520957947,
-0.1495247334241867,
0.7746978998184204,
-0.1255474090576172,
0.3159773051738739,
0.04951592907309532,
0.05866801738739014,
-0.09694480895996094,
-0.44047802686691284,
-0.649101972579956,
-0.403386652469635,
0.47682881355285645,
-0.2680474519729614,
0.2125952988862991... | |
LocationCombo.DisplayMemberPath =
}
```
and finally my LocationDB Class that is located in the App\_code folder in the asp web site:
```
[DataContract]
public class LocationDB
{
[DataMember]
public int Lid { get; set; }
[DataMember]
public int SmId { get; set; }
[DataMember]
public string Lname { g... | [
0.0372232124209404,
-0.20496799051761627,
0.765501856803894,
-0.21262261271476746,
0.34397709369659424,
0.09586618840694427,
-0.14413422346115112,
-0.008304216898977757,
-0.21240448951721191,
-0.9901488423347473,
-0.2725687623023987,
0.4358169436454773,
-0.1845126897096634,
0.2214432209730... | |
during application lifetime.
It looks like you should use only one Capture object in your application.
Simply move your Capture instantiation to Form constructor:
```
Capture capture;
public Form1()
{
InitializeComponent();
Application.Idle += new EventHandler(Capture);
capture = new Capture();
}
void ... | [
-0.01743658073246479,
-0.37212303280830383,
0.4859235882759094,
-0.2634373903274536,
0.2170967161655426,
-0.009232595562934875,
0.08765063434839249,
-0.3738608956336975,
-0.49561941623687744,
-0.6926654577255249,
-0.1652022898197174,
0.5440325736999512,
-0.5359621644020081,
0.1292980462312... | |
Let's assume, that we have an enumered type:
```
enum DataType { INT, DOUBLE };
```
And a type mapper:
```
template<DataType T>
struct TypeTraits {};
template<>
struct TypeTraits<INT> { typedef int T; };
template<>
struct TypeTraits<DOUBLE> { typedef double T; };
```
And a few templates which represents operat... | [
0.48446741700172424,
-0.31341129541397095,
0.5497472286224365,
-0.006613558623939753,
-0.20008757710456848,
0.21202172338962555,
0.36979812383651733,
-0.6861712336540222,
-0.049065228551626205,
-0.6915388107299805,
-0.4122244119644165,
0.566686749458313,
-0.8243591785430908,
0.105515100061... | |
Operation {
typedef typename TypeTraits<RetType>::T1 T1Type;
typedef typename TypeTraits<RetType>::T2 T2Type;
typedef typename TypeTraits<RetType>::RetType RType;
RType val;
Operation *c1, *c2;
Add(Operation *c1, Operation *c2) : c1(c1), c2(c2), Operation(RetType) {};
virtual void* compute(){
T1Ty... | [
0.18921735882759094,
-0.29866823554039,
0.6349154710769653,
-0.3013554513454437,
-0.22066563367843628,
0.2572093904018402,
0.5096681118011475,
-0.4590896964073181,
-0.31231212615966797,
-0.3783073425292969,
-0.43429940938949585,
0.7550692558288574,
-0.7519287467002869,
0.11688445508480072,... | |
child1 *AbstractNode;
child2 *AbstractNode;
}
```
We're reading a serialized abstract tree from input in order to translate it into an operation tree, and then - compute a result.
We want to write something like:
```
algebrator(Operation *op){
if(op->type == AbstractNode::INT_CONSTANT)
return new Constant<I... | [
-0.09553570300340652,
0.12393156439065933,
0.5312567949295044,
-0.02222820371389389,
0.26210418343544006,
0.40553194284439087,
-0.17519445717334747,
-0.49374622106552124,
-0.2109507918357849,
-0.5779201984405518,
-0.1988200843334198,
0.3288542628288269,
-0.41984832286834717,
-0.19093127548... | |
is something which specifies the return type of add operation based on operation arguments types.
And we fail of course and compiler will hit us into the faces. We can't use a variable as a template variable! It's because all information needed to instantiate template must be available during the compliation!
---
An... | [
0.4290826916694641,
0.17582276463508606,
-0.028093863278627396,
0.1544264703989029,
-0.016460925340652466,
-0.28300514817237854,
0.07769449055194855,
-0.3766053020954132,
-0.2206518054008484,
-0.2881166338920593,
-0.06516161561012268,
0.4538155496120453,
-0.3693898618221283,
0.187613978981... | |
write responses like "I think the whole example is messed up". I just want to know if there's a way to feed the template with variable, knowing it's from a finite, small set.
The whole thing may seem like an overkill, but I'm really curious how can I instantiate classes in such unusual situations.
Quick'n'dirty soluti... | [
0.22930815815925598,
0.06187956780195236,
0.19069772958755493,
-0.06429286301136017,
0.005709000863134861,
-0.036433491855859756,
0.6583776473999023,
-0.16723869740962982,
-0.006296772975474596,
-0.4868111312389374,
-0.18366020917892456,
0.6284000277519226,
-0.7506108283996582,
0.011856985... | |
// and instead of writing this:
switch (type) {
case INT:
PrintType<INT>();
break; | [
0.33180198073387146,
-0.15571244060993195,
0.08939287066459656,
-0.3187817633152008,
0.3593856692314148,
-0.07263202220201492,
0.2933419346809387,
-0.4544852077960968,
0.00023919192608445883,
-0.3862481117248535,
-0.41846391558647156,
0.5525344014167786,
-0.2450161874294281,
-0.04386128485... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.