How long does it take for a SIM card to activate (Europe)? –
travel.stackexchange.com
I have been wondering whether or not to buy a new SIM card when I take
side trips to countries bordering Germany (one for each country). However,
I have heard that each time I get a new SIM card, it …
Monday, 30 September 2013
Addresses of two pointers are same stackoverflow.com
Addresses of two pointers are same – stackoverflow.com
#include<stdio.h> #include<string.h> int main() { char * p = "abc"; char *
p1 = "abc"; printf("%d %d", p, p1); } When I print the addresses of the
two pointers, it is printing the …
#include<stdio.h> #include<string.h> int main() { char * p = "abc"; char *
p1 = "abc"; printf("%d %d", p, p1); } When I print the addresses of the
two pointers, it is printing the …
analyse time series in frequency domain with spectral analysis
analyse time series in frequency domain with spectral analysis
I have the following data:
286.6388889 1.026681635
286.6458333 1.016358286
286.6527778 1.009417537
286.6597222 1.028687388
286.6666667 1.028510939
286.6736111 0.94883809
286.6805556 0.846286541
286.6875 0.739437891
286.6944444 0.768898142
286.7013889 0.808513793
286.7083333 0.908196144
286.7152778 0.947781995
286.7222222 0.978898446
286.7291667 0.993943797
286.7361111 1.019133248
286.7430556 1.077287098
286.75 1.127817549
286.7569444 1.1580582
286.7638889 1.199274751
286.7708333 1.242171102
286.7777778 1.285057553
286.7847222 1.325402304
286.7916667 1.362363254
286.7986111 1.391722205
286.8055556 1.405890056
286.8125 1.405713007
286.8194444 1.386128858
286.8263889 1.390171509
286.8333333 1.40349566
286.8402778 1.41091221
286.8472222 1.433514661
286.8541667 1.490696612
286.8611111 1.554607563
286.8680556 1.657266314
286.875 1.651191865
286.8819444 1.650172916
286.8888889 1.671063567
286.8958333 1.653188717
286.9027778 1.561978268
286.9097222 1.515426219
286.9166667 1.46295927
286.9236111 1.421446621
286.9305556 1.432237372
286.9375 1.455681323
286.9444444 1.448756373
286.9513889 1.419896024
286.9583333 1.434905475
286.9652778 1.422917126
286.9722222 1.363674277
286.9791667 1.336490828
286.9861111 1.311835179
286.9930556 1.281267129
287 1.30472878
287.0069444 1.270779231
287.0138889 1.179396282
287.0208333 1.139513333
287.0277778 1.116522584
287.0347222 1.115500835
287.0416667 1.136448385
287.0486111 1.136271936
287.0555556 1.118350587
287.0625 1.088596138
287.0694444 1.063908989
287.0763889 1.06880334
287.0833333 1.033123391
287.0902778 1.045626442
287.0972222 1.118979792
287.1041667 1.127253143
287.1111111 1.099190394
287.1180556 1.079576245
287.125 1.110667896
287.1319444 1.119786347
287.1388889 1.116229598
287.1458333 1.091546048
287.1527778 1.032199999
287.1597222 0.95423135
287.1666667 0.860149201
287.1736111 0.827813852
287.1805556 0.853873003
287.1875 0.889231654
287.1944444 0.880596504
287.2013889 0.893111355
287.2083333 0.920852106
287.2152778 0.895291757
287.2222222 0.881581708
287.2291667 0.911860759
287.2361111 0.99626061
287.2430556 1.003693861
287.25 0.897791711
287.2569444 0.796067862
287.2638889 0.811127113
287.2708333 0.790634864
287.2777778 0.781146015
287.2847222 0.795360766
287.2916667 0.827348017
287.2986111 0.877944967
287.3055556 0.965741718
287.3125 0.954566969
287.3194444 0.80209232
287.3263889 0.768056071
287.3333333 0.789890322
287.3402778 0.825265173
287.3472222 0.814085223
287.3541667 0.803751274
287.3611111 0.825581225
287.3680556 0.870255676
287.375 0.939445427
287.3819444 1.033130578
287.3888889 1.094655129
287.3958333 1.147710979
287.4027778 1.18808193
287.4097222 1.221687781
287.4166667 1.246844632
287.4236111 1.261021383
287.4305556 1.281951134
287.4375 1.336641485
287.4444444 1.377816036
287.4513889 1.398733086
287.4583333 1.432302037
287.4652778 1.474299688
287.4722222 1.508699239
287.4791667 1.54730899
287.4861111 1.580853241
287.4930556 1.600063792
287.5 1.546778742
287.5069444 1.535641493
287.5138889 1.567501444
287.5208333 1.588398895
287.5277778 1.612665846
287.5347222 1.637772097
287.5416667 1.661190448
287.5486111 1.675337998
287.5555556 1.701279449
287.5625 1.7011028
287.5694444 1.726198351
287.5763889 1.724336802
287.5833333 1.730899053
287.5902778 1.708820104
287.5972222 1.669886155
287.6041667 1.551715005
287.6111111 1.554067756
287.6180556 1.548832607
287.625 1.544440558
287.6319444 1.556066709
287.6388889 1.56432026
287.6458333 1.553183911
287.6527778 1.558065361
287.6597222 1.566318912
287.6666667 1.566142363
287.6736111 1.587039214
287.6805556 1.587705365
287.6875 1.461025816
287.6944444 1.211059967
287.7013889 1.200736217
287.7083333 1.034103368
287.7152778 1.189403119
287.7222222 1.13938777
287.7291667 0.889822121
287.7361111 0.795722772
287.7430556 0.739669923
287.75 0.807208974
287.7569444 1.052324124
287.7638889 0.910935775
287.7708333 0.748269526
287.7777778 0.635449377
287.7847222 0.580192928
287.7916667 0.700314179
287.7986111 0.67727323
287.8055556 0.64406498
287.8125 0.609148231
287.8194444 0.575918982
287.8263889 0.617268033
287.8333333 0.629801384
287.8402778 0.671984635
287.8472222 0.647240586
287.8541667 0.591138536
287.8611111 0.577399687
287.8680556 0.710235838
287.875 0.854808789
287.8819444 0.93669534
287.8888889 0.805367791
287.8958333 0.705296242
287.9027778 0.685639792
287.9097222 0.685463443
287.9166667 0.680204694
287.9236111 0.707129645
287.9305556 0.767916196
287.9375 0.893827947
287.9444444 1.067834798
287.9513889 1.186785949
287.9583333 1.265984999
287.9652778 1.29451115
287.9722222 1.300242701
287.9791667 1.392890752
287.9861111 1.501521403
287.9930556 1.577222454
288 1.641098005
288.0069444 1.699057055
288.0138889 1.765422206
288.0208333 1.830925957
288.0277778 1.876209308
288.0347222 1.876874359
288.0416667 1.86743821
288.0486111 1.847899061
288.0555556 1.888127211
288.0625 1.948546262
288.0694444 1.980343813
288.0763889 2.002042464
288.0833333 2.009436915
288.0902778 2.027767366
288.0972222 2.031796617
288.1041667 2.045078468
288.1111111 2.042378618
288.1180556 2.016124569
288.125 2.00164622
288.1319444 1.993056471
288.1388889 1.970162722
288.1458333 1.976716973
288.1527778 1.946248524
288.1597222 1.892210074
288.1666667 1.769107825
288.1736111 1.660271976
288.1805556 1.545466227
288.1875 1.577328578
288.1944444 1.447302029
288.2013889 1.28680798
288.2083333 1.18784403
288.2152778 1.039812881
288.2222222 0.891660332
288.2291667 0.821260583
288.2361111 0.813467334
288.2430556 0.770121585
288.25 0.708985336
288.2569444 0.713042687
288.2638889 0.717946737
288.2708333 0.730470988
288.2777778 0.670165939
288.2847222 0.60560149
288.2916667 0.552881141
288.2986111 0.478944392
288.3055556 0.510141043
288.3125 0.533702893
288.3194444 0.535221944
288.3263889 0.550302895
288.3333333 0.589959746
288.3402778 0.642315597
288.3472222 0.698888248
288.3541667 0.748669999
288.3611111 0.781508449
288.3680556 0.8041844
288.375 0.832780951
288.3819444 0.843604202
288.3888889 0.871348153
288.3958333 0.887244604
288.4027778 0.889605555
288.4097222 0.875047505
288.4166667 0.784324456
288.4236111 0.800230807
288.4305556 0.770428858
288.4375 0.849788609
288.4444444 0.86824086
288.4513889 0.866369111
288.4583333 0.907641562
288.4652778 0.968358112
288.4722222 1.005381963
288.4791667 0.956166814
288.4861111 0.934003765
288.4930556 0.882232116
288.5 0.898972967
288.5069444 0.974904418
288.5138889 1.083767668
288.5208333 1.118232919
288.5277778 1.15015707
288.5347222 1.177853121
288.5416667 1.199633772
288.5486111 1.218034523
288.5555556 1.218702174
288.5625 1.169542824
288.5694444 1.081506275
288.5763889 0.941005026
288.5833333 0.889238977
288.5902778 0.904287528
288.5972222 0.861815779
288.6041667 0.89885933
288.6111111 0.968874081
288.6180556 1.038016131
288.625 1.118114782
288.6319444 1.194801933
288.6388889 1.248664084
288.6458333 1.288162635
288.6527778 1.325121286
288.6597222 1.367978637
288.6666667 1.411670687
288.6736111 1.433424538
288.6805556 1.459392489
288.6875 1.49294654
288.6944444 1.527337891
288.7013889 1.558351542
288.7083333 1.586832393
288.7152778 1.616994543
288.7222222 1.637884194
288.7291667 1.657928945
288.7361111 1.677971696
288.7430556 1.698012547
288.75 1.712155898
288.7569444 1.724613349
288.7638889 1.735385299
288.7708333 1.72257555
288.7777778 1.732505201
288.7847222 1.744961452
288.7916667 1.767522703
288.7986111 1.798501054
288.8055556 1.833684705
288.8125 1.828456356
288.8194444 1.803022606
288.8263889 1.849990357
288.8333333 1.873382508
288.8402778 1.864788559
288.8472222 1.86461201
288.8541667 1.898943161
288.8611111 1.887825512
288.8680556 1.917944762
288.875 1.953110113
288.8819444 1.979856464
288.8888889 2.025105515
288.8958333 2.082960166
288.9027778 2.127349317
288.9097222 2.135580568
288.9166667 1.978969018
288.9236111 1.915689669
288.9305556 1.84312992
288.9375 1.786545271
288.9444444 1.721525322
288.9513889 1.714610773
288.9583333 1.735489524
288.9652778 1.699936775
288.9722222 1.651742825
288.9791667 1.627973776
288.9861111 1.589874527
288.9930556 1.308830678
289 1.047722029
289.0069444 0.84292588
289.0138889 0.793671131
289.0208333 0.760485081
289.0277778 0.757768832
289.0347222 0.766056583
289.0416667 0.770112034
289.0486111 0.738614185
289.0555556 0.652062836
289.0625 0.614615487
289.0694444 0.617827337
289.0763889 0.637134788
289.0833333 0.642040839
289.0902778 0.63508729
289.0972222 0.650156941
289.1041667 0.685551492
289.1111111 0.704004043
289.1180556 0.724147894
289.125 0.743443244
289.1319444 0.741573095
289.1388889 0.748168846
289.1458333 0.748837797
289.1527778 0.763897948
289.1597222 0.806884499
289.1666667 0.80924675
289.1736111 0.814147
289.1805556 0.850352751
289.1875 0.900928802
289.1944444 0.907518653
289.2013889 0.848128304
289.2083333 0.835262455
289.2152778 0.884152306
289.2222222 0.889050656
289.2291667 0.888873907
289.2361111 0.914915258
289.2430556 0.954482009
289.25 0.93993096
289.2569444 0.935526311
289.2638889 0.944650762
289.2708333 0.955466212
289.2777778 0.967971263
289.2847222 0.988084014
289.2916667 1.013265665
289.2986111 1.051965016
289.3055556 1.093191267
289.3125 1.122582518
289.3194444 1.143522269
289.3263889 1.166993619
289.3333333 1.18455127
289.3402778 1.202106821
289.3472222 1.209529072
which shows the variation in air temperature measured at ten minutes
intervals (which I have converted into decimal days).
I'm attempting to compute the spectral properties of the time series in
order to see which periods are dominant. So far I have tried:
x = data(:,1);
y = data(:,2);
N = length(x);
% Time specifications:
Fs = 1; % samples per second, 10 minute samples
freq = 0:N-1; %Numerators of frequency series
freq = freq.*Fs./N;
% Fourier Transform:
X = fft(y)/N; % normalize the data
% find find nuquist frequency
cutOff = ceil(N./2);
% take only the first half of the spectrum
X = (X(1:cutOff));
% Frequency specifications:
freq = freq(1:cutOff);
% Plot the spectrum:
figure(i);
subplot(211);
plot(x,y);
subplot(212);
plot(freq,abs(X));
Is the sampling frequency specified here correct?
I am not convinced that I have done this correctly, could someone please
specify the correct or advised way of doing this? The reason I say that
this must not be correct is because I have a peak in the spectra at some
value that doesn't seem to mean much, and therefore would like to see how
someone who is experienced in performing these kinds of analysis would
tackle this.
I have the following data:
286.6388889 1.026681635
286.6458333 1.016358286
286.6527778 1.009417537
286.6597222 1.028687388
286.6666667 1.028510939
286.6736111 0.94883809
286.6805556 0.846286541
286.6875 0.739437891
286.6944444 0.768898142
286.7013889 0.808513793
286.7083333 0.908196144
286.7152778 0.947781995
286.7222222 0.978898446
286.7291667 0.993943797
286.7361111 1.019133248
286.7430556 1.077287098
286.75 1.127817549
286.7569444 1.1580582
286.7638889 1.199274751
286.7708333 1.242171102
286.7777778 1.285057553
286.7847222 1.325402304
286.7916667 1.362363254
286.7986111 1.391722205
286.8055556 1.405890056
286.8125 1.405713007
286.8194444 1.386128858
286.8263889 1.390171509
286.8333333 1.40349566
286.8402778 1.41091221
286.8472222 1.433514661
286.8541667 1.490696612
286.8611111 1.554607563
286.8680556 1.657266314
286.875 1.651191865
286.8819444 1.650172916
286.8888889 1.671063567
286.8958333 1.653188717
286.9027778 1.561978268
286.9097222 1.515426219
286.9166667 1.46295927
286.9236111 1.421446621
286.9305556 1.432237372
286.9375 1.455681323
286.9444444 1.448756373
286.9513889 1.419896024
286.9583333 1.434905475
286.9652778 1.422917126
286.9722222 1.363674277
286.9791667 1.336490828
286.9861111 1.311835179
286.9930556 1.281267129
287 1.30472878
287.0069444 1.270779231
287.0138889 1.179396282
287.0208333 1.139513333
287.0277778 1.116522584
287.0347222 1.115500835
287.0416667 1.136448385
287.0486111 1.136271936
287.0555556 1.118350587
287.0625 1.088596138
287.0694444 1.063908989
287.0763889 1.06880334
287.0833333 1.033123391
287.0902778 1.045626442
287.0972222 1.118979792
287.1041667 1.127253143
287.1111111 1.099190394
287.1180556 1.079576245
287.125 1.110667896
287.1319444 1.119786347
287.1388889 1.116229598
287.1458333 1.091546048
287.1527778 1.032199999
287.1597222 0.95423135
287.1666667 0.860149201
287.1736111 0.827813852
287.1805556 0.853873003
287.1875 0.889231654
287.1944444 0.880596504
287.2013889 0.893111355
287.2083333 0.920852106
287.2152778 0.895291757
287.2222222 0.881581708
287.2291667 0.911860759
287.2361111 0.99626061
287.2430556 1.003693861
287.25 0.897791711
287.2569444 0.796067862
287.2638889 0.811127113
287.2708333 0.790634864
287.2777778 0.781146015
287.2847222 0.795360766
287.2916667 0.827348017
287.2986111 0.877944967
287.3055556 0.965741718
287.3125 0.954566969
287.3194444 0.80209232
287.3263889 0.768056071
287.3333333 0.789890322
287.3402778 0.825265173
287.3472222 0.814085223
287.3541667 0.803751274
287.3611111 0.825581225
287.3680556 0.870255676
287.375 0.939445427
287.3819444 1.033130578
287.3888889 1.094655129
287.3958333 1.147710979
287.4027778 1.18808193
287.4097222 1.221687781
287.4166667 1.246844632
287.4236111 1.261021383
287.4305556 1.281951134
287.4375 1.336641485
287.4444444 1.377816036
287.4513889 1.398733086
287.4583333 1.432302037
287.4652778 1.474299688
287.4722222 1.508699239
287.4791667 1.54730899
287.4861111 1.580853241
287.4930556 1.600063792
287.5 1.546778742
287.5069444 1.535641493
287.5138889 1.567501444
287.5208333 1.588398895
287.5277778 1.612665846
287.5347222 1.637772097
287.5416667 1.661190448
287.5486111 1.675337998
287.5555556 1.701279449
287.5625 1.7011028
287.5694444 1.726198351
287.5763889 1.724336802
287.5833333 1.730899053
287.5902778 1.708820104
287.5972222 1.669886155
287.6041667 1.551715005
287.6111111 1.554067756
287.6180556 1.548832607
287.625 1.544440558
287.6319444 1.556066709
287.6388889 1.56432026
287.6458333 1.553183911
287.6527778 1.558065361
287.6597222 1.566318912
287.6666667 1.566142363
287.6736111 1.587039214
287.6805556 1.587705365
287.6875 1.461025816
287.6944444 1.211059967
287.7013889 1.200736217
287.7083333 1.034103368
287.7152778 1.189403119
287.7222222 1.13938777
287.7291667 0.889822121
287.7361111 0.795722772
287.7430556 0.739669923
287.75 0.807208974
287.7569444 1.052324124
287.7638889 0.910935775
287.7708333 0.748269526
287.7777778 0.635449377
287.7847222 0.580192928
287.7916667 0.700314179
287.7986111 0.67727323
287.8055556 0.64406498
287.8125 0.609148231
287.8194444 0.575918982
287.8263889 0.617268033
287.8333333 0.629801384
287.8402778 0.671984635
287.8472222 0.647240586
287.8541667 0.591138536
287.8611111 0.577399687
287.8680556 0.710235838
287.875 0.854808789
287.8819444 0.93669534
287.8888889 0.805367791
287.8958333 0.705296242
287.9027778 0.685639792
287.9097222 0.685463443
287.9166667 0.680204694
287.9236111 0.707129645
287.9305556 0.767916196
287.9375 0.893827947
287.9444444 1.067834798
287.9513889 1.186785949
287.9583333 1.265984999
287.9652778 1.29451115
287.9722222 1.300242701
287.9791667 1.392890752
287.9861111 1.501521403
287.9930556 1.577222454
288 1.641098005
288.0069444 1.699057055
288.0138889 1.765422206
288.0208333 1.830925957
288.0277778 1.876209308
288.0347222 1.876874359
288.0416667 1.86743821
288.0486111 1.847899061
288.0555556 1.888127211
288.0625 1.948546262
288.0694444 1.980343813
288.0763889 2.002042464
288.0833333 2.009436915
288.0902778 2.027767366
288.0972222 2.031796617
288.1041667 2.045078468
288.1111111 2.042378618
288.1180556 2.016124569
288.125 2.00164622
288.1319444 1.993056471
288.1388889 1.970162722
288.1458333 1.976716973
288.1527778 1.946248524
288.1597222 1.892210074
288.1666667 1.769107825
288.1736111 1.660271976
288.1805556 1.545466227
288.1875 1.577328578
288.1944444 1.447302029
288.2013889 1.28680798
288.2083333 1.18784403
288.2152778 1.039812881
288.2222222 0.891660332
288.2291667 0.821260583
288.2361111 0.813467334
288.2430556 0.770121585
288.25 0.708985336
288.2569444 0.713042687
288.2638889 0.717946737
288.2708333 0.730470988
288.2777778 0.670165939
288.2847222 0.60560149
288.2916667 0.552881141
288.2986111 0.478944392
288.3055556 0.510141043
288.3125 0.533702893
288.3194444 0.535221944
288.3263889 0.550302895
288.3333333 0.589959746
288.3402778 0.642315597
288.3472222 0.698888248
288.3541667 0.748669999
288.3611111 0.781508449
288.3680556 0.8041844
288.375 0.832780951
288.3819444 0.843604202
288.3888889 0.871348153
288.3958333 0.887244604
288.4027778 0.889605555
288.4097222 0.875047505
288.4166667 0.784324456
288.4236111 0.800230807
288.4305556 0.770428858
288.4375 0.849788609
288.4444444 0.86824086
288.4513889 0.866369111
288.4583333 0.907641562
288.4652778 0.968358112
288.4722222 1.005381963
288.4791667 0.956166814
288.4861111 0.934003765
288.4930556 0.882232116
288.5 0.898972967
288.5069444 0.974904418
288.5138889 1.083767668
288.5208333 1.118232919
288.5277778 1.15015707
288.5347222 1.177853121
288.5416667 1.199633772
288.5486111 1.218034523
288.5555556 1.218702174
288.5625 1.169542824
288.5694444 1.081506275
288.5763889 0.941005026
288.5833333 0.889238977
288.5902778 0.904287528
288.5972222 0.861815779
288.6041667 0.89885933
288.6111111 0.968874081
288.6180556 1.038016131
288.625 1.118114782
288.6319444 1.194801933
288.6388889 1.248664084
288.6458333 1.288162635
288.6527778 1.325121286
288.6597222 1.367978637
288.6666667 1.411670687
288.6736111 1.433424538
288.6805556 1.459392489
288.6875 1.49294654
288.6944444 1.527337891
288.7013889 1.558351542
288.7083333 1.586832393
288.7152778 1.616994543
288.7222222 1.637884194
288.7291667 1.657928945
288.7361111 1.677971696
288.7430556 1.698012547
288.75 1.712155898
288.7569444 1.724613349
288.7638889 1.735385299
288.7708333 1.72257555
288.7777778 1.732505201
288.7847222 1.744961452
288.7916667 1.767522703
288.7986111 1.798501054
288.8055556 1.833684705
288.8125 1.828456356
288.8194444 1.803022606
288.8263889 1.849990357
288.8333333 1.873382508
288.8402778 1.864788559
288.8472222 1.86461201
288.8541667 1.898943161
288.8611111 1.887825512
288.8680556 1.917944762
288.875 1.953110113
288.8819444 1.979856464
288.8888889 2.025105515
288.8958333 2.082960166
288.9027778 2.127349317
288.9097222 2.135580568
288.9166667 1.978969018
288.9236111 1.915689669
288.9305556 1.84312992
288.9375 1.786545271
288.9444444 1.721525322
288.9513889 1.714610773
288.9583333 1.735489524
288.9652778 1.699936775
288.9722222 1.651742825
288.9791667 1.627973776
288.9861111 1.589874527
288.9930556 1.308830678
289 1.047722029
289.0069444 0.84292588
289.0138889 0.793671131
289.0208333 0.760485081
289.0277778 0.757768832
289.0347222 0.766056583
289.0416667 0.770112034
289.0486111 0.738614185
289.0555556 0.652062836
289.0625 0.614615487
289.0694444 0.617827337
289.0763889 0.637134788
289.0833333 0.642040839
289.0902778 0.63508729
289.0972222 0.650156941
289.1041667 0.685551492
289.1111111 0.704004043
289.1180556 0.724147894
289.125 0.743443244
289.1319444 0.741573095
289.1388889 0.748168846
289.1458333 0.748837797
289.1527778 0.763897948
289.1597222 0.806884499
289.1666667 0.80924675
289.1736111 0.814147
289.1805556 0.850352751
289.1875 0.900928802
289.1944444 0.907518653
289.2013889 0.848128304
289.2083333 0.835262455
289.2152778 0.884152306
289.2222222 0.889050656
289.2291667 0.888873907
289.2361111 0.914915258
289.2430556 0.954482009
289.25 0.93993096
289.2569444 0.935526311
289.2638889 0.944650762
289.2708333 0.955466212
289.2777778 0.967971263
289.2847222 0.988084014
289.2916667 1.013265665
289.2986111 1.051965016
289.3055556 1.093191267
289.3125 1.122582518
289.3194444 1.143522269
289.3263889 1.166993619
289.3333333 1.18455127
289.3402778 1.202106821
289.3472222 1.209529072
which shows the variation in air temperature measured at ten minutes
intervals (which I have converted into decimal days).
I'm attempting to compute the spectral properties of the time series in
order to see which periods are dominant. So far I have tried:
x = data(:,1);
y = data(:,2);
N = length(x);
% Time specifications:
Fs = 1; % samples per second, 10 minute samples
freq = 0:N-1; %Numerators of frequency series
freq = freq.*Fs./N;
% Fourier Transform:
X = fft(y)/N; % normalize the data
% find find nuquist frequency
cutOff = ceil(N./2);
% take only the first half of the spectrum
X = (X(1:cutOff));
% Frequency specifications:
freq = freq(1:cutOff);
% Plot the spectrum:
figure(i);
subplot(211);
plot(x,y);
subplot(212);
plot(freq,abs(X));
Is the sampling frequency specified here correct?
I am not convinced that I have done this correctly, could someone please
specify the correct or advised way of doing this? The reason I say that
this must not be correct is because I have a peak in the spectra at some
value that doesn't seem to mean much, and therefore would like to see how
someone who is experienced in performing these kinds of analysis would
tackle this.
generate a meaningful random string using php
generate a meaningful random string using php
I would like to generate a random string with meaningful word
function randString($length, $charset='abcdefghijklmnopqrstuvwxyz'){
$str = '';
$count = strlen($charset);
while ($length--) {
$str .= $charset[mt_rand(0, $count-1)];
}
return $str;
}
I have used this function but it generate random which has not any meaning
in dictionary. Have you any idea or is it not possible. Please let me know
if you have any idea according or have better solution regarding.
Thanks in advance.
I would like to generate a random string with meaningful word
function randString($length, $charset='abcdefghijklmnopqrstuvwxyz'){
$str = '';
$count = strlen($charset);
while ($length--) {
$str .= $charset[mt_rand(0, $count-1)];
}
return $str;
}
I have used this function but it generate random which has not any meaning
in dictionary. Have you any idea or is it not possible. Please let me know
if you have any idea according or have better solution regarding.
Thanks in advance.
Sunday, 29 September 2013
[Andriod]how to obtain root privilege by an app(app) running as system-uid
[Andriod]how to obtain root privilege by an app(app) running as system-uid
I've set sharedUserId as "android.ui.system" in manifest and get it run as
system(uid). so now the apk has system privilege,but what should I do if I
want obtain root privilege on Android devices. by the way,the Android
devices haven't been rooted yet,there is no su.
thanks.
I've set sharedUserId as "android.ui.system" in manifest and get it run as
system(uid). so now the apk has system privilege,but what should I do if I
want obtain root privilege on Android devices. by the way,the Android
devices haven't been rooted yet,there is no su.
thanks.
Application auto start in default alarm application for android
Application auto start in default alarm application for android
There is auto start feature in default android alarm clock it is called
"Auto app starter" in Advanced settings. On this list is only a few items.
Is there any api from sdk which allows to register own application to this
list ? (I was not able to find anything like that).
Thanks in advance.
There is auto start feature in default android alarm clock it is called
"Auto app starter" in Advanced settings. On this list is only a few items.
Is there any api from sdk which allows to register own application to this
list ? (I was not able to find anything like that).
Thanks in advance.
Automatically wrap acronyms or words in caps with
Automatically wrap acronyms or words in caps with
I'd like to format all acronyms and words in caps automatically with a
<span> tag to format them via CSS.
Examples:
I live in the <span class="smcp">USA</span>.
My <span class="smcp">IP</span>-address is 0.0.0.0.
I'd like to format all acronyms and words in caps automatically with a
<span> tag to format them via CSS.
Examples:
I live in the <span class="smcp">USA</span>.
My <span class="smcp">IP</span>-address is 0.0.0.0.
Why hints are not visible when a cursor is over them?
Why hints are not visible when a cursor is over them?
My question concerns visibility of hints in an application using
DevExpress (C#) controls. The application has a panel on which there are
several controls, and only one appears at a given moment. A user can
choose which control should appear by switching among them. The controls
have their bar with several buttons (different buttons for each type of
control).
The problem is that the hints on the buttons sometimes do not appear when
the mouse cursor is over them. They appear after opening the application,
but when the user switches to a control of the same type, the hints are
not visible. When the user switches to a control of another type, the
hints can appear, but not always (I could not find the rule). But always,
when the user goes to a window of another application and returns, the
hints appear. The property ShowScreenTipsInToolbars for the bar manager
has the value true during execution of the program.
Do you know the cause of this strange behavior? And what to do to make the
hints always visible when a mouse cursor is over the buttons? I am not the
author of the application (I was asked if it is possible to solve the
problem) and I cannot give too many technical details.
My question concerns visibility of hints in an application using
DevExpress (C#) controls. The application has a panel on which there are
several controls, and only one appears at a given moment. A user can
choose which control should appear by switching among them. The controls
have their bar with several buttons (different buttons for each type of
control).
The problem is that the hints on the buttons sometimes do not appear when
the mouse cursor is over them. They appear after opening the application,
but when the user switches to a control of the same type, the hints are
not visible. When the user switches to a control of another type, the
hints can appear, but not always (I could not find the rule). But always,
when the user goes to a window of another application and returns, the
hints appear. The property ShowScreenTipsInToolbars for the bar manager
has the value true during execution of the program.
Do you know the cause of this strange behavior? And what to do to make the
hints always visible when a mouse cursor is over the buttons? I am not the
author of the application (I was asked if it is possible to solve the
problem) and I cannot give too many technical details.
Saturday, 28 September 2013
How to replace Linux Kernel error messages with my defined error messages?
How to replace Linux Kernel error messages with my defined error messages?
I have created a shell and when I give wrong number of arguments like
insufficient arguments to cp commands I receive the Linux shell error
message like what you will receive if you type cp fork.c as follows:
mysh> cp fork.c
cp: missing destination file operand after `fork.c'
Try `cp --help' for more information.
How can I bypass this error message and print my own error message like
Dude! this is an error ?
I have created a shell and when I give wrong number of arguments like
insufficient arguments to cp commands I receive the Linux shell error
message like what you will receive if you type cp fork.c as follows:
mysh> cp fork.c
cp: missing destination file operand after `fork.c'
Try `cp --help' for more information.
How can I bypass this error message and print my own error message like
Dude! this is an error ?
SERIOUS help port forwarding on my router?
SERIOUS help port forwarding on my router?
Okay, so I know that these kind of questions are pretty popular on SO, but
please hear me out. I have a belkin router, model F9K1102 v1. I also have
a Westell Dual Connection modem, model A90-220015-04. Now, I have done
port forwarding before, although it was with the same modem and a
different (Cisco) router. My modem is IP 192.168.0.47 and my router is
192.168.2.1. I followed the following tutorial to set up port forwarding
on the Belkin router:
http://portforward.com/english/routers/port_forwarding/Belkin/F9K1102v1/Apache.htm
And set up the following under "Virtual Servers":
Yet, whenever I try accessing my public IP (from whatsmyip.org) via my
iPhone on 4G, it can't find the server. The connection times out. Online
port sniffers say that port 80 isn't open. This is becoming very
frustrating and I really need it to work. Verizon is my ISP and I am
running Ubuntu Server 12.04, btw.
Any help towards resolving this would be GREATLY appreciated. Thanks in
advance!!
Okay, so I know that these kind of questions are pretty popular on SO, but
please hear me out. I have a belkin router, model F9K1102 v1. I also have
a Westell Dual Connection modem, model A90-220015-04. Now, I have done
port forwarding before, although it was with the same modem and a
different (Cisco) router. My modem is IP 192.168.0.47 and my router is
192.168.2.1. I followed the following tutorial to set up port forwarding
on the Belkin router:
http://portforward.com/english/routers/port_forwarding/Belkin/F9K1102v1/Apache.htm
And set up the following under "Virtual Servers":
Yet, whenever I try accessing my public IP (from whatsmyip.org) via my
iPhone on 4G, it can't find the server. The connection times out. Online
port sniffers say that port 80 isn't open. This is becoming very
frustrating and I really need it to work. Verizon is my ISP and I am
running Ubuntu Server 12.04, btw.
Any help towards resolving this would be GREATLY appreciated. Thanks in
advance!!
C-loops and goto
C-loops and goto
How can i remove the goto from the following code?
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
bool is_prime(unsigned num)
{
if(num==0 || num==1)
return false;
for(int i=2;i<num-1;i++)
if(num%i==0)
goto step;
return true;
step: return false;
}
int main(void)
{
unsigned n;
printf("enter the number: ");
scanf("%u",&n);
printf("%u\n",is_prime(n));
return 0;
}
How can i remove the goto from the following code?
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
bool is_prime(unsigned num)
{
if(num==0 || num==1)
return false;
for(int i=2;i<num-1;i++)
if(num%i==0)
goto step;
return true;
step: return false;
}
int main(void)
{
unsigned n;
printf("enter the number: ");
scanf("%u",&n);
printf("%u\n",is_prime(n));
return 0;
}
Strpos with both integer and word.
Strpos with both integer and word.
I'm stuck. Ignore the top line, no use for date yet, but will be using in
a bit. Having issues primarily with this line:
if(strpos($line, $extension) !== false and (preg_match('#\d#',$line !==
false))){
I'm trying to do is that if a domain name ($line) is a .com and has no
numbers then echo it. All of the preg_replace and strlen seems to be
working, but I can't get it to only perform the way I need. I need ot put
the preg_match outside of the <=40 rule as it may be causing confusion?
<?php
date_default_timezone_set('UTC');
$extension = '.com';
$lines = file('PoolDeletingDomainsList.txt');
echo "<b>4 Letter premiums for ". date("n/j/Y") .":</b><br />";
foreach($lines as $line)
if(strlen($line)<=40) {
{
// Check if the line contains the string we're looking for, and print if
it does
if(strpos($line, $extension) !== false and (preg_match('#\d#',$line !==
false))){
$line = preg_replace('/12:00:00 AM,AUC\b/','<br />', $line);
$line = preg_replace('/,9\/28\/2013/', '', $line);
echo $line;
}
}
}
?>
I'm stuck. Ignore the top line, no use for date yet, but will be using in
a bit. Having issues primarily with this line:
if(strpos($line, $extension) !== false and (preg_match('#\d#',$line !==
false))){
I'm trying to do is that if a domain name ($line) is a .com and has no
numbers then echo it. All of the preg_replace and strlen seems to be
working, but I can't get it to only perform the way I need. I need ot put
the preg_match outside of the <=40 rule as it may be causing confusion?
<?php
date_default_timezone_set('UTC');
$extension = '.com';
$lines = file('PoolDeletingDomainsList.txt');
echo "<b>4 Letter premiums for ". date("n/j/Y") .":</b><br />";
foreach($lines as $line)
if(strlen($line)<=40) {
{
// Check if the line contains the string we're looking for, and print if
it does
if(strpos($line, $extension) !== false and (preg_match('#\d#',$line !==
false))){
$line = preg_replace('/12:00:00 AM,AUC\b/','<br />', $line);
$line = preg_replace('/,9\/28\/2013/', '', $line);
echo $line;
}
}
}
?>
Friday, 27 September 2013
I just started using Titanium and I can't get the blank apps to open up the iOS Simulator
I just started using Titanium and I can't get the blank apps to open up
the iOS Simulator
I just started using Titanium (haven't even written any code yet), and
I've spent a while trying to get my simulators working. Android seems to
work, but I have to try and boot it up 3 times before it actually works
(then it is fine). iOS on the other hand just doesn't work.
I'm using Titanium 3.1.3.
I get the following messages in the console:
[INFO] : No module resources to copy
[INFO] : No CommonJS modules to copy
[INFO] : Compiling localization files
[INFO] : Skipping xcodebuild
[INFO] : Finished building the application in 13s 974ms
[INFO] : Running application in iOS Simulator
[INFO] : Launching application in iOS Simulator
[INFO] : Focusing the iOS Simulator
[INFO] : Application has exited from iOS Simulator
[INFO] : Project built successfully in 17s 497ms
Apparently there are no errors, but the simulator just doesn't pop up.
There are a few lines of code before all this I didn't include, but I
don't think those are important. Furthermore, I've looked all over the
internet and even Stackoverflow and I can't find a solution to my problem.
the iOS Simulator
I just started using Titanium (haven't even written any code yet), and
I've spent a while trying to get my simulators working. Android seems to
work, but I have to try and boot it up 3 times before it actually works
(then it is fine). iOS on the other hand just doesn't work.
I'm using Titanium 3.1.3.
I get the following messages in the console:
[INFO] : No module resources to copy
[INFO] : No CommonJS modules to copy
[INFO] : Compiling localization files
[INFO] : Skipping xcodebuild
[INFO] : Finished building the application in 13s 974ms
[INFO] : Running application in iOS Simulator
[INFO] : Launching application in iOS Simulator
[INFO] : Focusing the iOS Simulator
[INFO] : Application has exited from iOS Simulator
[INFO] : Project built successfully in 17s 497ms
Apparently there are no errors, but the simulator just doesn't pop up.
There are a few lines of code before all this I didn't include, but I
don't think those are important. Furthermore, I've looked all over the
internet and even Stackoverflow and I can't find a solution to my problem.
Sometimes, html pages generated with jstl don't render completely
Sometimes, html pages generated with jstl don't render completely
I am working with spring to make a web application. For UI, I use jstl.
But when I run the app on tomee, my page doesn't show up correctly. I have
looked at the html source code of the page in my browser and it's not
complete. It seems that jstl doesn't generate all the page. What can be
the reason of that ?
I am working with spring to make a web application. For UI, I use jstl.
But when I run the app on tomee, my page doesn't show up correctly. I have
looked at the html source code of the page in my browser and it's not
complete. It seems that jstl doesn't generate all the page. What can be
the reason of that ?
Try catch and re-throw exception
Try catch and re-throw exception
I saw some code the other day in one of our projects that uses a try catch
and re-throws the caught exception like this:
try
{
exceptionProneCode();
}
catch(Exception ex)
{
throw ex;
}
Nothing else was done with the exception in the catch block so I'm not
even sure why it's re-thrown. I can't see any benefit to actually throwing
the same exception again and doing nothing with the exception.
If you re-throw an exception that's caught in the catch block, how does C#
handle this? Does it get stuck in an infinite throw/catch loop? Or does it
eventually leave the try catch?
I saw some code the other day in one of our projects that uses a try catch
and re-throws the caught exception like this:
try
{
exceptionProneCode();
}
catch(Exception ex)
{
throw ex;
}
Nothing else was done with the exception in the catch block so I'm not
even sure why it's re-thrown. I can't see any benefit to actually throwing
the same exception again and doing nothing with the exception.
If you re-throw an exception that's caught in the catch block, how does C#
handle this? Does it get stuck in an infinite throw/catch loop? Or does it
eventually leave the try catch?
Linux C programming exec as user
Linux C programming exec as user
I have an program which I run as root. I would like the program to execute
another application as a normal user. I tried setgid() and it works, but I
can't then go back to root or another user. The program for the time being
is very simple;
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[] )
{
if ( argc != 2) {
printf("usage: %s command\n",argv[0]);
exit(1);
}
setgid(100);
setuid(1000);
putenv("HOME=/home/caroline");
putenv("DISPLAY=:0");
system(argv[1]);
seteuid(1001);
putenv("HOME=/home/john");
putenv("DISPLAY=:1");
system(argv[1]);
return 0;
}
How can I do this? It's like the action of command "su $user-c $command"
Respect R.
I have an program which I run as root. I would like the program to execute
another application as a normal user. I tried setgid() and it works, but I
can't then go back to root or another user. The program for the time being
is very simple;
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[] )
{
if ( argc != 2) {
printf("usage: %s command\n",argv[0]);
exit(1);
}
setgid(100);
setuid(1000);
putenv("HOME=/home/caroline");
putenv("DISPLAY=:0");
system(argv[1]);
seteuid(1001);
putenv("HOME=/home/john");
putenv("DISPLAY=:1");
system(argv[1]);
return 0;
}
How can I do this? It's like the action of command "su $user-c $command"
Respect R.
Thursday, 26 September 2013
UILabels within a UITableView cell are overlaying each other in iOS7
UILabels within a UITableView cell are overlaying each other in iOS7
I didn't have this problem with iOS6, but am currently having it with
iOS7. I have a UITableView and you can see 8 cells at the time the view is
loaded. Each populated with different names from and array. If you scroll
down, the next two cells look good, but everything past that gets text
laid on top of it; That text being the contents of what was in the
previous cells. So the 10th cell will have what was in the first cell, as
well as what is supposed to be in the 10th cell laid on top of it.
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
//Create Label for Name inside cell
UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake( 7.0,
5.0, 300.0, 30.0 )];
[name setText:[self.entriesArray objectAtIndex:indexPath.row]];
//Check to see if current person is a Parent or Child
NSString *class = [self.database
getCellDataWithMembership:[self.MembershipArray
objectAtIndex:indexPath.row] andColIndex:4];
if([class isEqualToString:@"CHILD"])
{
name.textColor = [UIColor colorWithRed:25.0f/255.0f
green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
name.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
}
[cell.contentView addSubview:name];
return cell;
}
My skill with Table views is makeshift at best. I've been reading lots of
documentation and researching solutions, but was not able to come up with
a solution. I just find it odd that it works perfect for iOS6, but not for
iOS7.
So it fetches a person's name from an array and I want to populate the
cells with those names. I was able to originally accomplish this using:
cell.textLabel.text = [self.entriesArray objectAtIndex:indexPath.row];
if([class isEqualToString:@"CHILD"])
{
cell.textLabel.textColor = [UIColor colorWithRed:25.0f/255.0f
green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
If I use that instead of the "name" UILabel actions from the first code
block, then it displays the names perfectly with no text overlay, but what
becomes an issue is the text color. If they are labeled as a CHILD then
they should be green text and bold. However, after scrolling down, every
person becomes green when they shouldn't be.
Sorry for the lengthy question. I've been working on this and racking my
brain around it and I just can't seem to figure it out. Any help would be
greatly appreciated.
I didn't have this problem with iOS6, but am currently having it with
iOS7. I have a UITableView and you can see 8 cells at the time the view is
loaded. Each populated with different names from and array. If you scroll
down, the next two cells look good, but everything past that gets text
laid on top of it; That text being the contents of what was in the
previous cells. So the 10th cell will have what was in the first cell, as
well as what is supposed to be in the 10th cell laid on top of it.
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
//Create Label for Name inside cell
UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake( 7.0,
5.0, 300.0, 30.0 )];
[name setText:[self.entriesArray objectAtIndex:indexPath.row]];
//Check to see if current person is a Parent or Child
NSString *class = [self.database
getCellDataWithMembership:[self.MembershipArray
objectAtIndex:indexPath.row] andColIndex:4];
if([class isEqualToString:@"CHILD"])
{
name.textColor = [UIColor colorWithRed:25.0f/255.0f
green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
name.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
}
[cell.contentView addSubview:name];
return cell;
}
My skill with Table views is makeshift at best. I've been reading lots of
documentation and researching solutions, but was not able to come up with
a solution. I just find it odd that it works perfect for iOS6, but not for
iOS7.
So it fetches a person's name from an array and I want to populate the
cells with those names. I was able to originally accomplish this using:
cell.textLabel.text = [self.entriesArray objectAtIndex:indexPath.row];
if([class isEqualToString:@"CHILD"])
{
cell.textLabel.textColor = [UIColor colorWithRed:25.0f/255.0f
green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
If I use that instead of the "name" UILabel actions from the first code
block, then it displays the names perfectly with no text overlay, but what
becomes an issue is the text color. If they are labeled as a CHILD then
they should be green text and bold. However, after scrolling down, every
person becomes green when they shouldn't be.
Sorry for the lengthy question. I've been working on this and racking my
brain around it and I just can't seem to figure it out. Any help would be
greatly appreciated.
Thursday, 19 September 2013
Get dynamic id when keyup trigerring using jquery/javascript
Get dynamic id when keyup trigerring using jquery/javascript
I have dynamically showing product list with price and quantity in text
box, i want to calculate product total price when enter the quantity.I
have done this by onclick when increase or decrease button.but i also need
to calculate the total price when key up quantity textbox
My code is like
<div id="gw_articles">
<div id="article_list">
<p>
<div id="article_1_element">
<input type="text" id="jform_article_1_name"
name="jform[article_1][name] " value="Spark plug ARH-II
AIW16 IRIDIUM+" disabled="disabled" size="35" /> <a
id="jform_article_1_modal">Select an product</a>
<input type="hidden" id="jform_article_1_id"
name="jform[article_1][id]" value="2" />
<input type="hidden" name="jform[article_1][price]"
id="jform_article_1_price" value="30.00" class="inputbox"
/>
<input type="text" name="jform[article_1][price_total]"
id="jform_article_1_price_total" value="90"
class="inputbox" size="10" />
<input type="text" name="jform[article_1][quantity]"
id="jform_article_1_quantity" value="3" class="inputbox"
size="10" />
<input type="button" class="btn" value="+"
onclick="document.id('jform_article_1_quantity').value++;
calculateTotalPrice('jform_article_1')" />
<input type="button" class="btn" value="-"
onclick="if(document.id('jform_article_1_quantity').value
>1)document.id('jform_article_1_quantity').value--;
calculateTotalPrice('jform_article_1')" /> <a title="test"
class="btn btn-danger"
onclick="removeElement('article_1_element')"> Delete </a>
</div>
</p>
<p>
<div id="article_2_element">
<input type="text" id="jform_article_2_name"
name="jform[article_2][name] " value="Spark plug ARH-II
AIW20 IRIDIUM+" disabled="disabled" size="35" /> <a
id="jform_article_2_modal" class="btn modal" title="Select
an product">Select an product</a>
<input type="hidden" id="jform_article_2_id"
name="jform[article_2][id]" value="1" />
<input type="hidden" name="jform[article_2][price]"
id="jform_article_2_price" value="40.00" class="inputbox"
/>
<input type="text" name="jform[article_2][price_total]"
id="jform_article_2_price_total" value="40"
class="inputbox" size="10" />
<input type="text" name="jform[article_2][quantity]"
id="jform_article_2_quantity" value="1" class="inputbox"
size="10" />
<input type="button" class="btn" value="+"
onclick="document.id('jform_article_2_quantity').value++;
calculateTotalPrice('jform_article_2')" />
<input type="button" class="btn" value="-"
onclick="if(document.id('jform_article_2_quantity').value
>1)document.id('jform_article_2_quantity').value--;
calculateTotalPrice('jform_article_2')" /> <a title="test"
class="btn btn-danger"
onclick="removeElement('article_2_element')"> Delete </a>
</div>
</p>
</div>
<input type="hidden" id="articles_max" name="articles_max" value="2" />
</div>
I have dynamically showing product list with price and quantity in text
box, i want to calculate product total price when enter the quantity.I
have done this by onclick when increase or decrease button.but i also need
to calculate the total price when key up quantity textbox
My code is like
<div id="gw_articles">
<div id="article_list">
<p>
<div id="article_1_element">
<input type="text" id="jform_article_1_name"
name="jform[article_1][name] " value="Spark plug ARH-II
AIW16 IRIDIUM+" disabled="disabled" size="35" /> <a
id="jform_article_1_modal">Select an product</a>
<input type="hidden" id="jform_article_1_id"
name="jform[article_1][id]" value="2" />
<input type="hidden" name="jform[article_1][price]"
id="jform_article_1_price" value="30.00" class="inputbox"
/>
<input type="text" name="jform[article_1][price_total]"
id="jform_article_1_price_total" value="90"
class="inputbox" size="10" />
<input type="text" name="jform[article_1][quantity]"
id="jform_article_1_quantity" value="3" class="inputbox"
size="10" />
<input type="button" class="btn" value="+"
onclick="document.id('jform_article_1_quantity').value++;
calculateTotalPrice('jform_article_1')" />
<input type="button" class="btn" value="-"
onclick="if(document.id('jform_article_1_quantity').value
>1)document.id('jform_article_1_quantity').value--;
calculateTotalPrice('jform_article_1')" /> <a title="test"
class="btn btn-danger"
onclick="removeElement('article_1_element')"> Delete </a>
</div>
</p>
<p>
<div id="article_2_element">
<input type="text" id="jform_article_2_name"
name="jform[article_2][name] " value="Spark plug ARH-II
AIW20 IRIDIUM+" disabled="disabled" size="35" /> <a
id="jform_article_2_modal" class="btn modal" title="Select
an product">Select an product</a>
<input type="hidden" id="jform_article_2_id"
name="jform[article_2][id]" value="1" />
<input type="hidden" name="jform[article_2][price]"
id="jform_article_2_price" value="40.00" class="inputbox"
/>
<input type="text" name="jform[article_2][price_total]"
id="jform_article_2_price_total" value="40"
class="inputbox" size="10" />
<input type="text" name="jform[article_2][quantity]"
id="jform_article_2_quantity" value="1" class="inputbox"
size="10" />
<input type="button" class="btn" value="+"
onclick="document.id('jform_article_2_quantity').value++;
calculateTotalPrice('jform_article_2')" />
<input type="button" class="btn" value="-"
onclick="if(document.id('jform_article_2_quantity').value
>1)document.id('jform_article_2_quantity').value--;
calculateTotalPrice('jform_article_2')" /> <a title="test"
class="btn btn-danger"
onclick="removeElement('article_2_element')"> Delete </a>
</div>
</p>
</div>
<input type="hidden" id="articles_max" name="articles_max" value="2" />
</div>
Fiddler2 + .NET solution for Java?
Fiddler2 + .NET solution for Java?
I coming from .NET development, to java.
I was enjoyed the combination of Fiddler2, great sniffer and usefull
extension, Request to Code
There is web sniffer or tool, which able convert http requests to java code?
Thanks!
I coming from .NET development, to java.
I was enjoyed the combination of Fiddler2, great sniffer and usefull
extension, Request to Code
There is web sniffer or tool, which able convert http requests to java code?
Thanks!
Cordova Media API - playAudio() is slow
Cordova Media API - playAudio() is slow
Does anyone have experience with playAudio() being really slow?
When I run
playAudio('http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3'),
it seems like it downloads the entire mp3 before even playing it.
Is there a way to start playing instantly? Or, is there a good example of
an implementation of the API that actually plays right away?
Does anyone have experience with playAudio() being really slow?
When I run
playAudio('http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3'),
it seems like it downloads the entire mp3 before even playing it.
Is there a way to start playing instantly? Or, is there a good example of
an implementation of the API that actually plays right away?
Convert continuous month scheme to date
Convert continuous month scheme to date
I have the following data frame
DateBA<-structure(list(PUBID = c(1, 8, 9, 10, 28, 31, 32, 33, 34, 35),
CVC_BA_DEGREE = c(281, 282, 305, 293, 317, 293, 281, 282,
329, 321)), datalabel = "", time.stamp = "19 Sep 2013 14:32", .Names =
c("PUBID",
"CVC_BA_DEGREE"), formats = c("%9.0g", "%9.0g"), types = c(254L,
254L), val.labels = c("vlR0000100", ""), var.labels = c("PUBID - YTH ID
CODE 1997",
"CVC_BA_DEGREE"), version = 12L, label.table = structure(list(
vlR0000100 = structure(0L, .Names = "0")), .Names = "vlR0000100"),
row.names = c(NA,
10L), class = "data.frame")
I want to convert DateBA$CVC_BA_DEGREE to a more workable format (month-year)
I know that January 1980 == 1 ; February 1980==2; December 1998 == 228
Thanks for the help!
I have the following data frame
DateBA<-structure(list(PUBID = c(1, 8, 9, 10, 28, 31, 32, 33, 34, 35),
CVC_BA_DEGREE = c(281, 282, 305, 293, 317, 293, 281, 282,
329, 321)), datalabel = "", time.stamp = "19 Sep 2013 14:32", .Names =
c("PUBID",
"CVC_BA_DEGREE"), formats = c("%9.0g", "%9.0g"), types = c(254L,
254L), val.labels = c("vlR0000100", ""), var.labels = c("PUBID - YTH ID
CODE 1997",
"CVC_BA_DEGREE"), version = 12L, label.table = structure(list(
vlR0000100 = structure(0L, .Names = "0")), .Names = "vlR0000100"),
row.names = c(NA,
10L), class = "data.frame")
I want to convert DateBA$CVC_BA_DEGREE to a more workable format (month-year)
I know that January 1980 == 1 ; February 1980==2; December 1998 == 228
Thanks for the help!
c# Extension method with restriction on MyClass convertation Error
c# Extension method with restriction on MyClass convertation Error
I have got an extension method with restriction on MyClass. What i try to do:
public static void GetXmlDocValues<T>(this List<T> collection, XmlDocument
xmlDoc) where T : MyClass
{
collection.Clear();
foreach (XmlNode item in xmlDoc.ChildNodes)
{
((List<MyClass>)collection).Add(new MyClass(item));
}
}
Then Ive got error: Cannot convert type
'System.Collections.Generic.List<T>' to
'System.Collections.Generic.List<MyProgram.MyClass>'.
Here:((List<MyClass>)collection)
Is it possible to do that stuff? Or it makes an error in any case.
I have got an extension method with restriction on MyClass. What i try to do:
public static void GetXmlDocValues<T>(this List<T> collection, XmlDocument
xmlDoc) where T : MyClass
{
collection.Clear();
foreach (XmlNode item in xmlDoc.ChildNodes)
{
((List<MyClass>)collection).Add(new MyClass(item));
}
}
Then Ive got error: Cannot convert type
'System.Collections.Generic.List<T>' to
'System.Collections.Generic.List<MyProgram.MyClass>'.
Here:((List<MyClass>)collection)
Is it possible to do that stuff? Or it makes an error in any case.
Django-CKEditor won't render images
Django-CKEditor won't render images
I've installed Django-CKEditor and configurated it for development purposes.
Now I can edit text and save it to db as text field. But with inserting
images I have major problems...
I can insert image and it seems to save properly to local host (to correct
folder) but when rendering image to preview or text editor I get only
broken image picture. Apparently I haven't configured settings.py
correctly. Main items from settings.py:
MEDIA_ROOT = ''
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
CKEDITOR_UPLOAD_PATH = 'media/uploads/'
CKEDITOR_UPLOAD_PREFIX = 'media/uploads/'
Also tried similar configuration than django-ckeditor testproject has but
faced similar broken rendering images.
I'm using windows environment for development
Any ideas what is wrong or where to start solving this?
I've installed Django-CKEditor and configurated it for development purposes.
Now I can edit text and save it to db as text field. But with inserting
images I have major problems...
I can insert image and it seems to save properly to local host (to correct
folder) but when rendering image to preview or text editor I get only
broken image picture. Apparently I haven't configured settings.py
correctly. Main items from settings.py:
MEDIA_ROOT = ''
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
CKEDITOR_UPLOAD_PATH = 'media/uploads/'
CKEDITOR_UPLOAD_PREFIX = 'media/uploads/'
Also tried similar configuration than django-ckeditor testproject has but
faced similar broken rendering images.
I'm using windows environment for development
Any ideas what is wrong or where to start solving this?
How to update mysql cols with comparison
How to update mysql cols with comparison
I have this table:
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| id | int(10) |
| confirm | int(5) |
| confirm_hold | int(5) |
| tmp | int(6) |
+----------------+--------------+
and have a some problem.
How can UPDATE some row. For example:
UPDATE `table` SET IF `tmp`>0 `confirm_hold`=123 ELSE `confirm`=123;
Thanks for all
I have this table:
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| id | int(10) |
| confirm | int(5) |
| confirm_hold | int(5) |
| tmp | int(6) |
+----------------+--------------+
and have a some problem.
How can UPDATE some row. For example:
UPDATE `table` SET IF `tmp`>0 `confirm_hold`=123 ELSE `confirm`=123;
Thanks for all
How can I login to cPanel different ways
How can I login to cPanel different ways
From how many ways can I log in to cPanel or In how many ways I can access
to my cPanel ?
I want to ask that is there any another way to login to cPanel ? Please
From how many ways can I log in to cPanel or In how many ways I can access
to my cPanel ?
I want to ask that is there any another way to login to cPanel ? Please
Wednesday, 18 September 2013
Are there any weather api that gives 10-day forecast?
Are there any weather api that gives 10-day forecast?
Can someone please help me find weather api for a 10-day forecast? In JSON
format would be better.
Can someone please help me find weather api for a 10-day forecast? In JSON
format would be better.
Difference between List
Difference between List
What's the difference between List<? extends MyClass> and List<MyClass>.
Don't both mean that I have a list with objects of MyClass?
What's the difference between List<? extends MyClass> and List<MyClass>.
Don't both mean that I have a list with objects of MyClass?
HTML 5 drag & drop save the layout or position - export to image or pdf
HTML 5 drag & drop save the layout or position - export to image or pdf
I am building the django website where I am using drag & drop html5
elements, what I would like to achieve is if I layout elements on the
screen to save it as PDF or Image or any available (simplest way) output
form.
I was looking at this solution:
http://jqueryui.com/droppable/#accepted-elements
Draggable & Droppable
Example have a frame on the website and 3 boxes inside and I can grab them
and position
them on the screen. And at the end to save it as PDF, Image or anything....
I am only throwing ideas, what would be the best approach to use that and
save it in some kind of viewable format, but simplest way doesn't need to
be complicated.
Thanks for help.
I am building the django website where I am using drag & drop html5
elements, what I would like to achieve is if I layout elements on the
screen to save it as PDF or Image or any available (simplest way) output
form.
I was looking at this solution:
http://jqueryui.com/droppable/#accepted-elements
Draggable & Droppable
Example have a frame on the website and 3 boxes inside and I can grab them
and position
them on the screen. And at the end to save it as PDF, Image or anything....
I am only throwing ideas, what would be the best approach to use that and
save it in some kind of viewable format, but simplest way doesn't need to
be complicated.
Thanks for help.
mapping between two text file contain arabic characters c#
mapping between two text file contain arabic characters c#
I have text file contains data like as:
ID 1 Name Mary Mark 89 ID 2 Name Mai Mark 67
and I have another txt file contains data : ID Mobile 1 0993209320 2
0943043094
I want to create excel file which contains only two columns: Mobile
Message 0993209320 ID 1 Name Mary Mark 89 0943043094 ID 2 Name Mai Mark 67
to do this,I tried the following code, it works fine, and the required
excel file was created, but when I change the data contained in both text
file to Arabic, the code created excel file, but Empty, what should I do
to modify the code to make it able to deal with arabic character??
this is the code:
DataTable dtMapping = new DataTable();
ArrayList lstMapping = new ArrayList();
dtMapping.Columns.Add("Mobile"); dtMapping.Columns.Add("Message");
string[] readFile1 = File.ReadAllLines(Location of 1st file);
string[] readFile2 = File.ReadAllLines(Location of 2nd file);
for (int i = 0; i < readFile1.Length; i++)
{
string fileData = readFile1[i].ToString();
int find_Id_Index = fileData.IndexOf("ID ");
if (find_Id_Index != -1)
{
int find_Name_Index = fileData.IndexOf("Name ",
find_Id_Index);
string id =
fileData.Substring(find_Id_Index+3,find_Name_Index-(find_Id_Index+3)
).Trim();
lstMapping.Add("ID " + id);
lstMapping.Add(fileData.Substring(find_Name_Index,
fileData.Length - (find_Name_Index)).Trim());
}
}
for (int i = 1; i < readFile2.Length; i++)
{
int find_Space_Index = readFile2[i].IndexOf(" ");
if (find_Space_Index != -1)
{
string file2id = readFile2[i].Substring(0,
find_Space_Index).Trim();
string mobileno =
readFile2[i].Substring(find_Space_Index,
readFile2[2].Length - (find_Space_Index -
file2id.Length+1)).Trim();
int find_Id = lstMapping.IndexOf("ID " + file2id);
if (find_Id != -1)
{
dtMapping.Rows.Add(mobileno, "ID " + file2id + " "
+ lstMapping[find_Id + 1]);
}
}
}
Microsoft.Office.Interop.Excel.Application excelApp = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook =
excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Worksheet workSheet =
(Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
for (int i = 0; i < dtMapping.Columns.Count; i++)
{
workSheet.Cells[1, (i + 1)] =
dtMapping.Columns[i].ColumnName;
}
for (int i = 0; i < dtMapping.Rows.Count; i++)
{
for (int j = 0; j < dtMapping.Columns.Count; j++)
{
workSheet.Cells[(i + 2), (j + 1)] = dtMapping.Rows[i][j];
}
}
excelApp.Visible = true;
I have text file contains data like as:
ID 1 Name Mary Mark 89 ID 2 Name Mai Mark 67
and I have another txt file contains data : ID Mobile 1 0993209320 2
0943043094
I want to create excel file which contains only two columns: Mobile
Message 0993209320 ID 1 Name Mary Mark 89 0943043094 ID 2 Name Mai Mark 67
to do this,I tried the following code, it works fine, and the required
excel file was created, but when I change the data contained in both text
file to Arabic, the code created excel file, but Empty, what should I do
to modify the code to make it able to deal with arabic character??
this is the code:
DataTable dtMapping = new DataTable();
ArrayList lstMapping = new ArrayList();
dtMapping.Columns.Add("Mobile"); dtMapping.Columns.Add("Message");
string[] readFile1 = File.ReadAllLines(Location of 1st file);
string[] readFile2 = File.ReadAllLines(Location of 2nd file);
for (int i = 0; i < readFile1.Length; i++)
{
string fileData = readFile1[i].ToString();
int find_Id_Index = fileData.IndexOf("ID ");
if (find_Id_Index != -1)
{
int find_Name_Index = fileData.IndexOf("Name ",
find_Id_Index);
string id =
fileData.Substring(find_Id_Index+3,find_Name_Index-(find_Id_Index+3)
).Trim();
lstMapping.Add("ID " + id);
lstMapping.Add(fileData.Substring(find_Name_Index,
fileData.Length - (find_Name_Index)).Trim());
}
}
for (int i = 1; i < readFile2.Length; i++)
{
int find_Space_Index = readFile2[i].IndexOf(" ");
if (find_Space_Index != -1)
{
string file2id = readFile2[i].Substring(0,
find_Space_Index).Trim();
string mobileno =
readFile2[i].Substring(find_Space_Index,
readFile2[2].Length - (find_Space_Index -
file2id.Length+1)).Trim();
int find_Id = lstMapping.IndexOf("ID " + file2id);
if (find_Id != -1)
{
dtMapping.Rows.Add(mobileno, "ID " + file2id + " "
+ lstMapping[find_Id + 1]);
}
}
}
Microsoft.Office.Interop.Excel.Application excelApp = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook =
excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Worksheet workSheet =
(Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
for (int i = 0; i < dtMapping.Columns.Count; i++)
{
workSheet.Cells[1, (i + 1)] =
dtMapping.Columns[i].ColumnName;
}
for (int i = 0; i < dtMapping.Rows.Count; i++)
{
for (int j = 0; j < dtMapping.Columns.Count; j++)
{
workSheet.Cells[(i + 2), (j + 1)] = dtMapping.Rows[i][j];
}
}
excelApp.Visible = true;
How to load search data from twitter onto a website?
How to load search data from twitter onto a website?
I'm in the process of making a website that will show users the latest
tweets people have made about a few different topics. My idea was to use
python on the server to do a search through the twitter API every few
minutes, and after doing some parsing, drop the results into a database.
Then when users access the website, it would use javascript to access
either a python or php file on the server to fill in the divs on the site
with the tweets.
Is this the best way to manage what I want? A majority of the users will
be accessing the site from their phones, so I'd rather keep the load times
down as much as possible. Any advice would be appreciated.
I'm in the process of making a website that will show users the latest
tweets people have made about a few different topics. My idea was to use
python on the server to do a search through the twitter API every few
minutes, and after doing some parsing, drop the results into a database.
Then when users access the website, it would use javascript to access
either a python or php file on the server to fill in the divs on the site
with the tweets.
Is this the best way to manage what I want? A majority of the users will
be accessing the site from their phones, so I'd rather keep the load times
down as much as possible. Any advice would be appreciated.
Scrapping html between two html comments using nokogiri
Scrapping html between two html comments using nokogiri
I have some html pages where the contents to be extracted are marked with
html comments like below.
.....
<!-- begin content -->
...
Some html elements goes here
<!-- end content -->
...
I am using Nokogiri and trying to extract the html between these comments.
I can get the text only version using the characters callback but i need
full html between these comments.
I am rather new in web scrapping so please any help is appreciated.
I have some html pages where the contents to be extracted are marked with
html comments like below.
.....
<!-- begin content -->
...
Some html elements goes here
<!-- end content -->
...
I am using Nokogiri and trying to extract the html between these comments.
I can get the text only version using the characters callback but i need
full html between these comments.
I am rather new in web scrapping so please any help is appreciated.
which is best to save image in the photo library?
which is best to save image in the photo library?
I have came across two ideas of saving images from app to photo library.
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL
completionSelector, void *contextInfo);
2.ALAssetsLibrary
I used the first one but it takes more time to save.I need to know which
is fast to save images in library.
I have came across two ideas of saving images from app to photo library.
UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL
completionSelector, void *contextInfo);
2.ALAssetsLibrary
I used the first one but it takes more time to save.I need to know which
is fast to save images in library.
Tuesday, 17 September 2013
how can i seperately change contents of tags with a specific property
how can i seperately change contents of tags with a specific property
I have 4 "td" tags in my page. every "td" includes a "date and time" like
this:
<td nowrap="">
25/6/1392 14:34
</td>
I want to change the place of day and year: 1392/6/25 14:34 I used below
code:
var van=$("td [nowrap='']:contains('/1392')").text();
var too=van.split(' ');
var tri=too[0];
var fouur=tri.split('/');
$("td
[nowrap='']:contains('/1392')").text(fouur[2]+'/'+fouur[1]+'/'+fouur[0]+'
'+too[1]);
but this code just changes the first td content to what I want and changes
all other td contents to the first td. please help
I have 4 "td" tags in my page. every "td" includes a "date and time" like
this:
<td nowrap="">
25/6/1392 14:34
</td>
I want to change the place of day and year: 1392/6/25 14:34 I used below
code:
var van=$("td [nowrap='']:contains('/1392')").text();
var too=van.split(' ');
var tri=too[0];
var fouur=tri.split('/');
$("td
[nowrap='']:contains('/1392')").text(fouur[2]+'/'+fouur[1]+'/'+fouur[0]+'
'+too[1]);
but this code just changes the first td content to what I want and changes
all other td contents to the first td. please help
Intel Pentium Floating-Point Division Bug, 1994 used on Python
Intel Pentium Floating-Point Division Bug, 1994 used on Python
This math equation...
(4195835 / 3145727) * 3145727 - 4195835
is supposed to equate to 0. According to the book Software Testing (2nd Ed),
If you get anything else, you have an old Intel Pentium CPU with a
floating-point division buga software bug burned into a computer chip and
reproduced over and over in the manufacturing process.
Using Python 2.7, I get -1050108 in command line.
Using Node I get 0, just as I would in the calculator
Any deeper explanation for this? This was originally brought up due to a
bug in the video game Disney's Lion King, 1994. I thought I would test the
equation on a few things.
This math equation...
(4195835 / 3145727) * 3145727 - 4195835
is supposed to equate to 0. According to the book Software Testing (2nd Ed),
If you get anything else, you have an old Intel Pentium CPU with a
floating-point division buga software bug burned into a computer chip and
reproduced over and over in the manufacturing process.
Using Python 2.7, I get -1050108 in command line.
Using Node I get 0, just as I would in the calculator
Any deeper explanation for this? This was originally brought up due to a
bug in the video game Disney's Lion King, 1994. I thought I would test the
equation on a few things.
MIPS multiplication via addition
MIPS multiplication via addition
I'm currently using QtSpim for a MIPS program. The objective is to use
addition to multiply. This is my code which is relatively straightforward:
.data
inputX: .word 5
inputY: .word 4
tempX: .word 0
constantOne: .word 1
finalX: .word 0
.text
main:
lw $t1, inputX
lw $t2, inputY
lw $t0, tempX
lw $t3, constantOne
lw $t4, finalX
beq $t2, $zero, Exit #when Y equals zero, X is already zero so exits.
Loop: beq $t2, $t3, yIsOne #when y is one skip rest of loop
add $t0, $t1, $t1 #actual "multiplication".
sub $t2, $t2, $t3 #what makes loop continue
bne $t2, $zero, Loop #while Y isnt yet 0.
yIsOne: add $t0, $t0, $t1 #adds X to 0 or the multiplied Xs
Exit:
sw $t4, finalX
When I run the program, I get this:
R8 [t0] = f
R9 [t1] = 5
R10 [t2] = 1
R11 [t3] = 1
R12 [t4] = 0
which was very baffling so I went through single-step and the first time
t0 should've had 5 added to its total, it became a. It stayed that way
until after my yIsOne jump, which is where it became f. Everything else
appears to work fine. It jumps back up for the loop correctly. t2 gets
subtracted by one every time. Any help is appreciated. Thanks.
I'm currently using QtSpim for a MIPS program. The objective is to use
addition to multiply. This is my code which is relatively straightforward:
.data
inputX: .word 5
inputY: .word 4
tempX: .word 0
constantOne: .word 1
finalX: .word 0
.text
main:
lw $t1, inputX
lw $t2, inputY
lw $t0, tempX
lw $t3, constantOne
lw $t4, finalX
beq $t2, $zero, Exit #when Y equals zero, X is already zero so exits.
Loop: beq $t2, $t3, yIsOne #when y is one skip rest of loop
add $t0, $t1, $t1 #actual "multiplication".
sub $t2, $t2, $t3 #what makes loop continue
bne $t2, $zero, Loop #while Y isnt yet 0.
yIsOne: add $t0, $t0, $t1 #adds X to 0 or the multiplied Xs
Exit:
sw $t4, finalX
When I run the program, I get this:
R8 [t0] = f
R9 [t1] = 5
R10 [t2] = 1
R11 [t3] = 1
R12 [t4] = 0
which was very baffling so I went through single-step and the first time
t0 should've had 5 added to its total, it became a. It stayed that way
until after my yIsOne jump, which is where it became f. Everything else
appears to work fine. It jumps back up for the loop correctly. t2 gets
subtracted by one every time. Any help is appreciated. Thanks.
How to custom format a cell in an AdvancedDataGrid in flex?
How to custom format a cell in an AdvancedDataGrid in flex?
I would like to create an AdvancedDataGrid where one of the cells requires
some layout work involving images and text. Here is the top level view of
the problem that I am trying to solve
(My grid looks like this - Property "name" in the first column and
Property "value" in the second)
<mx:AdvancedDataGrid showHeaders="false" defaultLeafIcon="{null}">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Property"
headerText="Property" backgroundColor="#E5EFF5" width="0.4"
wordWrap="true"/>
<mx:AdvancedDataGridColumn dataField="Value" headerText="Value"
backgroundColor="white" width="0.6"/>
</mx:columns>
</mx:AdvancedDataGrid>
(The dataProvider for the grid looks something like the following)
var retVal:ArrayCollection = new ArrayCollection([
{Property:'AA', Value:1},
{Property:'BB', Value: <Object that requires custom formatting when
displayed in the grid>},
{Property:'CC', Value:"Simple string"}
]);
Property BB alone has a more complex view involving laying out images and
text in a particular layout. Every other property has a simple string or
numeric value that does not require any special formatting.
Things like itemRenderer are proving to be too difficult to use for me
given that not all my column entries for a given column are formatted in
the same way when displayed inside the grid.
I am using an AdvancedDataGrid because it provides tree like navigation
within the grid (using children) and that is something that I will
eventually need.
An example would be helpful as I am new to flex.
Thank you.
I would like to create an AdvancedDataGrid where one of the cells requires
some layout work involving images and text. Here is the top level view of
the problem that I am trying to solve
(My grid looks like this - Property "name" in the first column and
Property "value" in the second)
<mx:AdvancedDataGrid showHeaders="false" defaultLeafIcon="{null}">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Property"
headerText="Property" backgroundColor="#E5EFF5" width="0.4"
wordWrap="true"/>
<mx:AdvancedDataGridColumn dataField="Value" headerText="Value"
backgroundColor="white" width="0.6"/>
</mx:columns>
</mx:AdvancedDataGrid>
(The dataProvider for the grid looks something like the following)
var retVal:ArrayCollection = new ArrayCollection([
{Property:'AA', Value:1},
{Property:'BB', Value: <Object that requires custom formatting when
displayed in the grid>},
{Property:'CC', Value:"Simple string"}
]);
Property BB alone has a more complex view involving laying out images and
text in a particular layout. Every other property has a simple string or
numeric value that does not require any special formatting.
Things like itemRenderer are proving to be too difficult to use for me
given that not all my column entries for a given column are formatted in
the same way when displayed inside the grid.
I am using an AdvancedDataGrid because it provides tree like navigation
within the grid (using children) and that is something that I will
eventually need.
An example would be helpful as I am new to flex.
Thank you.
Convert timestamp into year, month, days, hours, minutes, seconds in PHP
Convert timestamp into year, month, days, hours, minutes, seconds in PHP
I need to convert datetime into year, month, days, hours, minutes,
seconds; my date is saved in database like this: 2011-11-30 05:25:50.
Now I want to show like year, month, days, hours, minutes and seconds in
PHP like: 2 year,5 month 10 days, 10 hours, 45 minutes, 30 seconds.
I have searched about this but not understand how I can do this,I know
there are many questions at this topic on Stack Overflow, maybe it is
duplicate but I am unable to solve my issue.
Thanks in advance.
I need to convert datetime into year, month, days, hours, minutes,
seconds; my date is saved in database like this: 2011-11-30 05:25:50.
Now I want to show like year, month, days, hours, minutes and seconds in
PHP like: 2 year,5 month 10 days, 10 hours, 45 minutes, 30 seconds.
I have searched about this but not understand how I can do this,I know
there are many questions at this topic on Stack Overflow, maybe it is
duplicate but I am unable to solve my issue.
Thanks in advance.
Cropping an image taken from AVCaptureStillImageOutput
Cropping an image taken from AVCaptureStillImageOutput
I am trying to crop an image taken from AVCaptureStillImageOutput but
unable to properly crop at the correct rectangles.
My preview of camera video is 320x458 frame and the cropping rectangle is
present inside this preview frame which has the co-ordinates and size as
CGRectMake(60, 20, 200, 420).
After taking the picture, I receive the image from
NSData *imageData = [AVCaptureStillImageOutput
jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
UIImage *finalImage = [self cropImage:image];
Afterwards I am trying to crop this actual image of size 1080x1920 with
the below function. I am getting a wayward clipping and the resultant
image is way out of the actual rectangle! ;(
- (UIImage *)cropImage:(UIImage *)oldImage {
CGRect rect = CGRectMake(60, 20, 200, 420);
CGSize boundSize = CGSizeMake(320, 458);
float widthFactor = rect.size.width *
(oldImage.size.width/boundSize.width);
float heightFactor = rect.size.height *
(oldImage.size.height/boundSize.height);
float factorX = rect.origin.x * (oldImage.size.width/boundSize.width);
float factorY = rect.origin.y * (oldImage.size.height/boundSize.height);
CGRect factoredRect =
CGRectMake(factorX,factorY,widthFactor,heightFactor);
UIImage *croppedImage = [UIImage
imageWithCGImage:CGImageCreateWithImageInRect([oldImage CGImage],
factoredRect) scale:oldImage.scale
orientation:oldImage.imageOrientation];
return croppedImage;
}
In the attached picture, I am trying to crop the coffee mug, but what I
get is not the correct cropped image!
I am trying to crop an image taken from AVCaptureStillImageOutput but
unable to properly crop at the correct rectangles.
My preview of camera video is 320x458 frame and the cropping rectangle is
present inside this preview frame which has the co-ordinates and size as
CGRectMake(60, 20, 200, 420).
After taking the picture, I receive the image from
NSData *imageData = [AVCaptureStillImageOutput
jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
UIImage *finalImage = [self cropImage:image];
Afterwards I am trying to crop this actual image of size 1080x1920 with
the below function. I am getting a wayward clipping and the resultant
image is way out of the actual rectangle! ;(
- (UIImage *)cropImage:(UIImage *)oldImage {
CGRect rect = CGRectMake(60, 20, 200, 420);
CGSize boundSize = CGSizeMake(320, 458);
float widthFactor = rect.size.width *
(oldImage.size.width/boundSize.width);
float heightFactor = rect.size.height *
(oldImage.size.height/boundSize.height);
float factorX = rect.origin.x * (oldImage.size.width/boundSize.width);
float factorY = rect.origin.y * (oldImage.size.height/boundSize.height);
CGRect factoredRect =
CGRectMake(factorX,factorY,widthFactor,heightFactor);
UIImage *croppedImage = [UIImage
imageWithCGImage:CGImageCreateWithImageInRect([oldImage CGImage],
factoredRect) scale:oldImage.scale
orientation:oldImage.imageOrientation];
return croppedImage;
}
In the attached picture, I am trying to crop the coffee mug, but what I
get is not the correct cropped image!
Sunday, 15 September 2013
send http request post with raw data in Javascript and retrieve with Perl
send http request post with raw data in Javascript and retrieve with Perl
experts, some questions to ask, very grateful for your guidance.
I saw some rest client like Chrome Postman provided 2 ways of Post
request: form data and raw data. I see raw data can be in JSON format. I
didn't know how to implement this request in Javascript.
How can I handle this request if I use Perl as server side language? How
to retrieve the JSON data from the request?
Does the Get method put arguments in url as "?name=value&", while Post
method in some format of data such as JSON/XML? Does that the main
difference of the 2 methods? Get arguments can be got by parsing url,
method type can from ENV variable value, so how the JSON data was
transmitted?
experts, some questions to ask, very grateful for your guidance.
I saw some rest client like Chrome Postman provided 2 ways of Post
request: form data and raw data. I see raw data can be in JSON format. I
didn't know how to implement this request in Javascript.
How can I handle this request if I use Perl as server side language? How
to retrieve the JSON data from the request?
Does the Get method put arguments in url as "?name=value&", while Post
method in some format of data such as JSON/XML? Does that the main
difference of the 2 methods? Get arguments can be got by parsing url,
method type can from ENV variable value, so how the JSON data was
transmitted?
Webapp - Best method to limite usage of user
Webapp - Best method to limite usage of user
I'm building a webapp where I would like to limit the user of over using
the application.
I would like to limit how many time the user send email notification each
month.
The way I was thinking of doing this is by logging every notification with
user_id date time. So before Sending a notification I will select * WHERE
user_id Between Date and Date+30. And do a validation that the number of
entry is smaller then the limit.
Is there an easy and faster way to do this. I'm a bit nervous when I will
have 1/2 millions logging entry.
I'm building a webapp where I would like to limit the user of over using
the application.
I would like to limit how many time the user send email notification each
month.
The way I was thinking of doing this is by logging every notification with
user_id date time. So before Sending a notification I will select * WHERE
user_id Between Date and Date+30. And do a validation that the number of
entry is smaller then the limit.
Is there an easy and faster way to do this. I'm a bit nervous when I will
have 1/2 millions logging entry.
Splash screen slides up on slide up action
Splash screen slides up on slide up action
I have a splash screen on my app.
What I want to do is slide this up, which will open the next activity. I
don't understand whether to implement this splash as another activity or..
well, I don't know how to make this happen.
I have a splash screen on my app.
What I want to do is slide this up, which will open the next activity. I
don't understand whether to implement this splash as another activity or..
well, I don't know how to make this happen.
Trying to understand Ruby arrays
Trying to understand Ruby arrays
array = [:peanut, :butter, :and, :jelly]
Why array[4,0] is [] and array[5,0] is nil ?
I'm new to ruby, sorry if this is a basic question.
array = [:peanut, :butter, :and, :jelly]
Why array[4,0] is [] and array[5,0] is nil ?
I'm new to ruby, sorry if this is a basic question.
Creating an Options Menu in Android
Creating an Options Menu in Android
I'm trying to make an option menu in android like this link
http://developer.android.com/guide/topics/ui/menus.html#options-menu
but my developed menu shows not on bottom of my page but in top action bar.
my xml is bellow my_options_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/menu_addnew"
android:title="ÍÝï"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/menu_addnew"
android:title="ÂïÞèåéá" />
</menu>
and my java code is
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.new_game:
//newGame();
return true;
case R.id.help:
//showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
What can I do to show the menu on bottom of my application and not on top
action bar?
I'm trying to make an option menu in android like this link
http://developer.android.com/guide/topics/ui/menus.html#options-menu
but my developed menu shows not on bottom of my page but in top action bar.
my xml is bellow my_options_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/menu_addnew"
android:title="ÍÝï"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/menu_addnew"
android:title="ÂïÞèåéá" />
</menu>
and my java code is
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.new_game:
//newGame();
return true;
case R.id.help:
//showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
What can I do to show the menu on bottom of my application and not on top
action bar?
Java - Synchronized
Java - Synchronized
Hi i have made a something that extends thread that adds adds an object
that has a IP in it. then i made two instances of this thread and started
them. they use the same list.
I now want to use Synchronized to stop the concurrent update problem. But
its not working and i cant work out why.
My main class:
import java.util.*;
import java.io.*;
import java.net.*;
class ListTest2{
public static LinkedList<Peer> myList = new LinkedList<Peer>();
public static void main(String [] args){
try{
AddIp test1 = new AddIp(myList);
AddIp test2 = new AddIp(myList);
test1.start();
test2.start();
}
catch(Exception e){System.out.println("not working");}
}
}
My thread class:
class AddIp extends Thread{
public static int startIp =0;
List<Peer> myList;
public AddIp(List<Peer> l){
myList = l;
}
public synchronized void run() {
try{
startIp = startIp+50;
int ip = startIp;
InetAddress address = InetAddress.getByName("127.0.0.0");
Peer peer = new Peer(address);
while(ip <startIp+50){
ip++;
address = InetAddress.getByName("127.0.0."+ip);
peer = new Peer(address);
myList.add(peer);
if(myList.indexOf(peer)== (myList.size() -1)){}
else{System.out.println("Lost"+peer.peerIp);}
}
}catch(Exception e){}
}
}
Can anyone help me out here im lost for ideas thanks.
Hi i have made a something that extends thread that adds adds an object
that has a IP in it. then i made two instances of this thread and started
them. they use the same list.
I now want to use Synchronized to stop the concurrent update problem. But
its not working and i cant work out why.
My main class:
import java.util.*;
import java.io.*;
import java.net.*;
class ListTest2{
public static LinkedList<Peer> myList = new LinkedList<Peer>();
public static void main(String [] args){
try{
AddIp test1 = new AddIp(myList);
AddIp test2 = new AddIp(myList);
test1.start();
test2.start();
}
catch(Exception e){System.out.println("not working");}
}
}
My thread class:
class AddIp extends Thread{
public static int startIp =0;
List<Peer> myList;
public AddIp(List<Peer> l){
myList = l;
}
public synchronized void run() {
try{
startIp = startIp+50;
int ip = startIp;
InetAddress address = InetAddress.getByName("127.0.0.0");
Peer peer = new Peer(address);
while(ip <startIp+50){
ip++;
address = InetAddress.getByName("127.0.0."+ip);
peer = new Peer(address);
myList.add(peer);
if(myList.indexOf(peer)== (myList.size() -1)){}
else{System.out.println("Lost"+peer.peerIp);}
}
}catch(Exception e){}
}
}
Can anyone help me out here im lost for ideas thanks.
Saturday, 14 September 2013
Syntax issue with python dictionary and multiprocessing script
Syntax issue with python dictionary and multiprocessing script
Hi I am trying to be able to start a thread from a dictionary entry using
this code below. The rest of the code in the script is known good and
fully functional. I cam gonna have to be able to choose from a bunch of
different subroutines so I want to remove as much boilerplate as possible
from the code. Thanks guys and gals!!!!
class worker_manager:
i = test_imports()
template('one': i.import_1, 'two': i.import_2);
def __init__(self):
self.children = {}
def generate(self, control_Queue, threadName, runNum):
p = multiprocessing.Process(target=self.template[threadName],
args=(control_Queue, runNum))
self.children[threadName] = p
p.start()
def terminate(self, threadName):
self.children[threadName].join
When I run this code I get this error:
File "dynamicTest1.py", line 53
template('one': i.import_1, 'two': i.import_2);
^
SyntaxError: invalid syntax
Anyone have any advice?
Hi I am trying to be able to start a thread from a dictionary entry using
this code below. The rest of the code in the script is known good and
fully functional. I cam gonna have to be able to choose from a bunch of
different subroutines so I want to remove as much boilerplate as possible
from the code. Thanks guys and gals!!!!
class worker_manager:
i = test_imports()
template('one': i.import_1, 'two': i.import_2);
def __init__(self):
self.children = {}
def generate(self, control_Queue, threadName, runNum):
p = multiprocessing.Process(target=self.template[threadName],
args=(control_Queue, runNum))
self.children[threadName] = p
p.start()
def terminate(self, threadName):
self.children[threadName].join
When I run this code I get this error:
File "dynamicTest1.py", line 53
template('one': i.import_1, 'two': i.import_2);
^
SyntaxError: invalid syntax
Anyone have any advice?
Experiences with ECL (Embeddeed Common Lisp)
Experiences with ECL (Embeddeed Common Lisp)
Waay back (July 2010), the question was asked:
Does anybody here have a experience with Common Lisp as a embedded
language (using ECL)? >If so, how good is ECL compared to Lua?
http://stackoverflow.com/users/388921/linkit
Which went off into how easy or otherwise Lua is. So far as I can see,
no-one addresseed the question about ECL. SO, Does anyone have experience
using ECL, and is it OK. Don't bother with how much you love or hate some
alternative embedded language, please just tell me about ECL. TIA
Waay back (July 2010), the question was asked:
Does anybody here have a experience with Common Lisp as a embedded
language (using ECL)? >If so, how good is ECL compared to Lua?
http://stackoverflow.com/users/388921/linkit
Which went off into how easy or otherwise Lua is. So far as I can see,
no-one addresseed the question about ECL. SO, Does anyone have experience
using ECL, and is it OK. Don't bother with how much you love or hate some
alternative embedded language, please just tell me about ECL. TIA
Need help drawing light though the vexter shader
Need help drawing light though the vexter shader
I need some help with "drawing" out specular light thought the vexter
shader instead of the pixel shader , since my teacher want to prove a
point that it wont work properly.. I have tried to solve it myself , but I
can't mange to solve it..
The original code :
struct Light
{
float3 pos;
float range;
float3 dir;
float cone;
float3 att;
float4 ambient;
float4 diffuse;
};
cbuffer cbPerFrame
{
Light light;
};
cbuffer cbPerObject
{
float4x4 WVP;
float4x4 World;
};
Texture2D ObjTexture;
SamplerState ObjSamplerState;
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 worldPos : POSITION;
float2 TexCoord : TEXCOORD;
float3 normal : NORMAL;
};
VS_OUTPUT VS(float4 inPos : POSITION, float2 inTexCoord : TEXCOORD, float3
normal : NORMAL)
{
VS_OUTPUT output;
output.Pos = mul(inPos, WVP);
output.worldPos = mul(inPos, World);
output.normal = mul(normal, World);
output.TexCoord = inTexCoord;
return output;
}
float4 PS(VS_OUTPUT input) : SV_TARGET
{
input.normal = normalize(input.normal);
float4 diffuse = ObjTexture.Sample( ObjSamplerState, input.TexCoord );
float3 finalColor = float3(0.0f, 0.0f, 0.0f);
//Create the vector between light position and pixels position
float3 lightToPixelVec = light.pos - input.worldPos;
//Find the distance between the light pos and pixel pos
float d = length(lightToPixelVec);
//Add the ambient light
float3 finalAmbient = diffuse * light.ambient;
//If pixel is too far, return pixel color with ambient light
if( d > light.range )
return float4(finalAmbient, diffuse.a);
//Turn lightToPixelVec into a unit length vector describing
//the pixels direction from the lights position
lightToPixelVec /= d;
//Calculate how much light the pixel gets by the angle
//in which the light strikes the pixels surface
float howMuchLight = dot(lightToPixelVec, input.normal);
//If light is striking the front side of the pixel
if( howMuchLight > 0.0f )
{
//Add light to the finalColor of the pixel
finalColor += diffuse * light.diffuse;
//Calculate Light's Distance Falloff factor
finalColor /= (light.att[0] + (light.att[1] * d)) + (light.att[2]
* (d*d));
//Calculate falloff from center to edge of pointlight cone
finalColor *= pow(max(dot(-lightToPixelVec, light.dir), 0.0f),
light.cone);
}
//make sure the values are between 1 and 0, and add the ambient
finalColor = saturate(finalColor + finalAmbient);
//Return Final Color
return float4(finalColor, diffuse.a);
}
float4 D2D_PS(VS_OUTPUT input) : SV_TARGET
{
float4 diffuse = ObjTexture.Sample( ObjSamplerState, input.TexCoord );
return diffuse;
}
I need some help with "drawing" out specular light thought the vexter
shader instead of the pixel shader , since my teacher want to prove a
point that it wont work properly.. I have tried to solve it myself , but I
can't mange to solve it..
The original code :
struct Light
{
float3 pos;
float range;
float3 dir;
float cone;
float3 att;
float4 ambient;
float4 diffuse;
};
cbuffer cbPerFrame
{
Light light;
};
cbuffer cbPerObject
{
float4x4 WVP;
float4x4 World;
};
Texture2D ObjTexture;
SamplerState ObjSamplerState;
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 worldPos : POSITION;
float2 TexCoord : TEXCOORD;
float3 normal : NORMAL;
};
VS_OUTPUT VS(float4 inPos : POSITION, float2 inTexCoord : TEXCOORD, float3
normal : NORMAL)
{
VS_OUTPUT output;
output.Pos = mul(inPos, WVP);
output.worldPos = mul(inPos, World);
output.normal = mul(normal, World);
output.TexCoord = inTexCoord;
return output;
}
float4 PS(VS_OUTPUT input) : SV_TARGET
{
input.normal = normalize(input.normal);
float4 diffuse = ObjTexture.Sample( ObjSamplerState, input.TexCoord );
float3 finalColor = float3(0.0f, 0.0f, 0.0f);
//Create the vector between light position and pixels position
float3 lightToPixelVec = light.pos - input.worldPos;
//Find the distance between the light pos and pixel pos
float d = length(lightToPixelVec);
//Add the ambient light
float3 finalAmbient = diffuse * light.ambient;
//If pixel is too far, return pixel color with ambient light
if( d > light.range )
return float4(finalAmbient, diffuse.a);
//Turn lightToPixelVec into a unit length vector describing
//the pixels direction from the lights position
lightToPixelVec /= d;
//Calculate how much light the pixel gets by the angle
//in which the light strikes the pixels surface
float howMuchLight = dot(lightToPixelVec, input.normal);
//If light is striking the front side of the pixel
if( howMuchLight > 0.0f )
{
//Add light to the finalColor of the pixel
finalColor += diffuse * light.diffuse;
//Calculate Light's Distance Falloff factor
finalColor /= (light.att[0] + (light.att[1] * d)) + (light.att[2]
* (d*d));
//Calculate falloff from center to edge of pointlight cone
finalColor *= pow(max(dot(-lightToPixelVec, light.dir), 0.0f),
light.cone);
}
//make sure the values are between 1 and 0, and add the ambient
finalColor = saturate(finalColor + finalAmbient);
//Return Final Color
return float4(finalColor, diffuse.a);
}
float4 D2D_PS(VS_OUTPUT input) : SV_TARGET
{
float4 diffuse = ObjTexture.Sample( ObjSamplerState, input.TexCoord );
return diffuse;
}
What's the technology behind Amazon test drive?
What's the technology behind Amazon test drive?
How they project the screen on webpage? Is there normal way to fetch media
stream from android?
How they project the screen on webpage? Is there normal way to fetch media
stream from android?
Facebook apprequest error
Facebook apprequest error
Hello
I have made an app on facebook , but when I click to invite it is work on
my account .. and send requests , but any other accounts doesn't work I
mean it is not send requests .. it is give me this error :
An error occurred. Please try again later.
============================== and this is the code invite :
(function(d){
var js, id = 'facebook-jssdk', ref =
d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function closePopup(){
$('#_DialogDiv').css({visibility: "hidden"});
$('#_DialogDiv').hide();
}
function share_pic(pic_details, access_token)
{
$("#share_text").text("SHARED");
$("#share_text_new").text("SHARED");
$.ajax({
url:
'share.php?pic_details='+pic_details+'&access_token='+access_token,
success: function(data) {
}
});
}
window.fbAsyncInit = function() {
var curLoc = window.location;
FB.init({
appId : '617160745002785',
xfbml : true,
oauth : true,
cookie: true,
});
FB.Canvas.setAutoGrow();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
function inviteFriends(message){
FB.ui({ method: 'apprequests',
message: message,
data:"617160745002785"
});
}
var davet_m="",davet_t="Suggest to Friends",kkk=0;
function mshuffle(o){
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x
= o[--i], o[i] = o[j], o[j] = x);
return o;
};
function sendRequestToFriends(txxt,title){
davet_m=txxt;
if (title)
davet_t=title;
FB.login(function(response) {
if (response.authResponse) {
if(!kkk) {
kkk=1;
//$.post("/justhtml/181411457193/email",{"token":response.authResponse.accessToken},function(data)
{});
}
all();
}
else {
all();
}
}, {scope: 'email'});
}
function all(){
var friends = new Array();
FB.api('/me/friends', function(response) {
for (var i=0; i<response.data.length; i++) {
friends[i] = response.data[i].id;
//alert(friends[i]);
}
mshuffle(friends);
loop(friends);
});
}
var GG_NUM=15;
function loop(list){
if(list.length != 0){
//alert(list.length);
var string = '';
var shifting = 0;
if (list.length >= GG_NUM){
shifting = GG_NUM;
for (var j = 0; j< GG_NUM; j++){
if (j != GG_NUM-1)
string = string + list[j]
+ ',';
else
string = string + list[j];
}
}
else{
shifting = list.length;
for (var j = 0; j< list.length; j++){
if (j != list.length - 1)
string = string + list[j]
+ ',';
else
string = string + list[j];
}
}
string = "'" + string + "'";
FB.ui({method: 'apprequests', data:
'617160745002785', message: 'Invite',
title: 'invite', to : string},
function(response) {
if (response) {
closePopup();
}
else{
}
});
} else {
}
}
Hello
I have made an app on facebook , but when I click to invite it is work on
my account .. and send requests , but any other accounts doesn't work I
mean it is not send requests .. it is give me this error :
An error occurred. Please try again later.
============================== and this is the code invite :
(function(d){
var js, id = 'facebook-jssdk', ref =
d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function closePopup(){
$('#_DialogDiv').css({visibility: "hidden"});
$('#_DialogDiv').hide();
}
function share_pic(pic_details, access_token)
{
$("#share_text").text("SHARED");
$("#share_text_new").text("SHARED");
$.ajax({
url:
'share.php?pic_details='+pic_details+'&access_token='+access_token,
success: function(data) {
}
});
}
window.fbAsyncInit = function() {
var curLoc = window.location;
FB.init({
appId : '617160745002785',
xfbml : true,
oauth : true,
cookie: true,
});
FB.Canvas.setAutoGrow();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
function inviteFriends(message){
FB.ui({ method: 'apprequests',
message: message,
data:"617160745002785"
});
}
var davet_m="",davet_t="Suggest to Friends",kkk=0;
function mshuffle(o){
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x
= o[--i], o[i] = o[j], o[j] = x);
return o;
};
function sendRequestToFriends(txxt,title){
davet_m=txxt;
if (title)
davet_t=title;
FB.login(function(response) {
if (response.authResponse) {
if(!kkk) {
kkk=1;
//$.post("/justhtml/181411457193/email",{"token":response.authResponse.accessToken},function(data)
{});
}
all();
}
else {
all();
}
}, {scope: 'email'});
}
function all(){
var friends = new Array();
FB.api('/me/friends', function(response) {
for (var i=0; i<response.data.length; i++) {
friends[i] = response.data[i].id;
//alert(friends[i]);
}
mshuffle(friends);
loop(friends);
});
}
var GG_NUM=15;
function loop(list){
if(list.length != 0){
//alert(list.length);
var string = '';
var shifting = 0;
if (list.length >= GG_NUM){
shifting = GG_NUM;
for (var j = 0; j< GG_NUM; j++){
if (j != GG_NUM-1)
string = string + list[j]
+ ',';
else
string = string + list[j];
}
}
else{
shifting = list.length;
for (var j = 0; j< list.length; j++){
if (j != list.length - 1)
string = string + list[j]
+ ',';
else
string = string + list[j];
}
}
string = "'" + string + "'";
FB.ui({method: 'apprequests', data:
'617160745002785', message: 'Invite',
title: 'invite', to : string},
function(response) {
if (response) {
closePopup();
}
else{
}
});
} else {
}
}
What value is returned on yylex() function when I undefined expression in flex?
What value is returned on yylex() function when I undefined expression in
flex?
if i undefined any expression between %% and %% What value is returned ?
thank you
flex?
if i undefined any expression between %% and %% What value is returned ?
thank you
Friday, 13 September 2013
Regex Matching Unicode Characters acting oddly with different strings
Regex Matching Unicode Characters acting oddly with different strings
Ok, I am doing a unicode regex match on some strings.
These are the strings in question.
\u2018Mummy\u2019 Reboot May Get \u2018Mama\u2019 Director
\u2018Glee\u2019 Star Grant Gustin to Play The Flash in \u2018Arrow\u2019
Season 2
And I am using this regex to parse out the titles surround in unicode quotes.
regex = re.compile("\\u2018[^(?!\\u2018$)]*\\u2019",re.UNICODE)
using regex.findall() returns me
['u2018Mama\\u2019']
and
['u2018Glee\\u2019', 'u2018Arrow\\u2019']
This brings up two questions that I couldn't figure out. why isn't it
returning \u2018, where is the initial \?
Secondly, what is different. I can't see it. Finally, I replaced \u2018
and \u2019 with '. Then using this regex.
re.compile("'[^']*'")
It matches both in both strings. What is the difference here? What am I
missing in the unicode regex?
Thank you in advance.
Ok, I am doing a unicode regex match on some strings.
These are the strings in question.
\u2018Mummy\u2019 Reboot May Get \u2018Mama\u2019 Director
\u2018Glee\u2019 Star Grant Gustin to Play The Flash in \u2018Arrow\u2019
Season 2
And I am using this regex to parse out the titles surround in unicode quotes.
regex = re.compile("\\u2018[^(?!\\u2018$)]*\\u2019",re.UNICODE)
using regex.findall() returns me
['u2018Mama\\u2019']
and
['u2018Glee\\u2019', 'u2018Arrow\\u2019']
This brings up two questions that I couldn't figure out. why isn't it
returning \u2018, where is the initial \?
Secondly, what is different. I can't see it. Finally, I replaced \u2018
and \u2019 with '. Then using this regex.
re.compile("'[^']*'")
It matches both in both strings. What is the difference here? What am I
missing in the unicode regex?
Thank you in advance.
SVG is not loading properly in Mobile Safari
SVG is not loading properly in Mobile Safari
I was able to get fonts to load in Android but when it came to iOs the
.svg file seems to not load properly.
In iOs, it seems that it is still using the default Apple font for
converting "Shruti" (Gujarati font). This conversion causes issues in font
rendering. Thats why I was resorting to supply the "Shruti" font by using
svg. However its not loading properly.
Here is the definition I am using :
@font-face {
font-family: "Shruti";
src: url('http://www.bhajansangrah.com/shruti.eot?') format('eot'),
url('http://www.bhajansangrah.com/shruti.woff') format('woff'),
url('http://www.bhajansangrah.com/shruti.ttf') format('truetype'),
url('http://www.bhajansangrah.com/shruti.svg#Shruti') format('svg');
} div { font-family: "Shruti", Verdana, Tahoma; }
Here is an example site: http://www.bhajansangrah.com/index.php?title=96
So for example, in line 1 we see that the text should be
"બાદશાહી
ગૌરવ બિરાજે,
ત્રાતાના
લલાટે,"
which appears fine on all browsers, including Android, except for Mobile
Safari (my guess is that its not loading the svg file properly)
In iOs (Mobile safari) it shows up as, incorrectly :
I was able to get fonts to load in Android but when it came to iOs the
.svg file seems to not load properly.
In iOs, it seems that it is still using the default Apple font for
converting "Shruti" (Gujarati font). This conversion causes issues in font
rendering. Thats why I was resorting to supply the "Shruti" font by using
svg. However its not loading properly.
Here is the definition I am using :
@font-face {
font-family: "Shruti";
src: url('http://www.bhajansangrah.com/shruti.eot?') format('eot'),
url('http://www.bhajansangrah.com/shruti.woff') format('woff'),
url('http://www.bhajansangrah.com/shruti.ttf') format('truetype'),
url('http://www.bhajansangrah.com/shruti.svg#Shruti') format('svg');
} div { font-family: "Shruti", Verdana, Tahoma; }
Here is an example site: http://www.bhajansangrah.com/index.php?title=96
So for example, in line 1 we see that the text should be
"બાદશાહી
ગૌરવ બિરાજે,
ત્રાતાના
લલાટે,"
which appears fine on all browsers, including Android, except for Mobile
Safari (my guess is that its not loading the svg file properly)
In iOs (Mobile safari) it shows up as, incorrectly :
Example for Responsive Kendo UI grid
Example for Responsive Kendo UI grid
I have implemented KendoUI in my WebApp, is there any way of making the
grid responsive? Like, showing fewer columns on smaller resolutions!
I have implemented KendoUI in my WebApp, is there any way of making the
grid responsive? Like, showing fewer columns on smaller resolutions!
Overwriting class object due to string parsing issue
Overwriting class object due to string parsing issue
I am trying to read a fixed width text file and store each element to a
class object. Each row in the text file needs to be checked for which
parsing action must be performed. Rows 1000 and 1001 each need to be
parsed differently and rows 1002-1004 use the same parsing action. I am
reading the file and parsing correctly, but when I add elements to the
class object the object gets overwritten in each "if" statement. Then when
the object is added to a list the list contains empty lines. I feel like I
am taking the wrong approach. I am new to C# and I apologize if this has
been answered, but after many hours of searching I cannot find a solution.
Below is the text file and code.
1000 AttributeOne AttributeTwo
1001 123456.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 456789.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 234567.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 345678.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0 3456.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
namespace list_question
{
public class someObject
{
//Line 1
public int Line1_ID;
public string Line1_Attribute1;
public string Line1_Attribute2;
//Line 2
public int Line2_ID;
public decimal Line2_Attribute3;
public string Line2_Attribute4;
//Line 3
public int Line3_ID;
public decimal data_pos1;
public decimal data_pos2;
public decimal data_pos3;
}
class Program
{
static void Main(string[] args)
{
string filepathRead = @"C:\Users\C121736\Desktop\SampleFile.txt";
List<someObject> somObList = new List<someObject>();
someObject obj = new someObject();
try
{
FileStream fs = new FileStream(filepathRead,
FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if ((line.Substring(0, 4) == "1000"))
{
string[] strArrFields1 = Regex.Split(line,
@"(.{6})" + "(.{14})" + "(.{20})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line1_ID =
int.Parse(strArrFields1[0].TrimEnd(' '));
obj_1.Line1_Attribute1 =
strArrFields1[1].TrimEnd(' ');
obj_1.Line1_Attribute2 =
strArrFields1[2].TrimEnd(' ');
somObList.Add(obj_1);
}
else if ((line.Substring(0, 4) == "1001"))
{
string[] strArrFields2 = Regex.Split(line,
@"(.{6})" + "(.{20})" + "(.{15})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line2_ID =
int.Parse(strArrFields2[0].TrimEnd(' '));
obj_1.Line2_Attribute3 =
decimal.Parse(strArrFields2[1].TrimEnd(' '));
obj_1.Line2_Attribute4 =
strArrFields2[2].TrimEnd(' ');
somObList.Add(obj_1);
}
else
{
string[] strArrFields3 = Regex.Split(line,
@"(.{6})" + "(.{7})" + "(.{7})" +
"(.{7})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line3_ID =
int.Parse(strArrFields3[0].TrimEnd(' '));
obj_1.data_pos1 =
decimal.Parse(strArrFields3[1].TrimEnd(' '));
obj_1.data_pos2 =
decimal.Parse(strArrFields3[2].TrimEnd(' '));
obj_1.data_pos3 =
decimal.Parse(strArrFields3[3].TrimEnd(' '));
somObList.Add(obj_1);
}
}
}
catch (FileNotFoundException ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Program Exited");
Environment.Exit(99);
}
foreach (someObject o in somObList)
{
Console.WriteLine("{0},{1},{2}\n{3},{4},{5}\n{6},{7},{8},{9}",
o.Line1_ID, o.Line1_Attribute1, o.Line1_Attribute2,
o.Line2_ID, o.Line2_Attribute3, o.Line2_Attribute4,
o.Line3_ID, o.data_pos1, o.data_pos2, o.data_pos3);
}
somObList.Clear();
}
}
}
I am trying to read a fixed width text file and store each element to a
class object. Each row in the text file needs to be checked for which
parsing action must be performed. Rows 1000 and 1001 each need to be
parsed differently and rows 1002-1004 use the same parsing action. I am
reading the file and parsing correctly, but when I add elements to the
class object the object gets overwritten in each "if" statement. Then when
the object is added to a list the list contains empty lines. I feel like I
am taking the wrong approach. I am new to C# and I apologize if this has
been answered, but after many hours of searching I cannot find a solution.
Below is the text file and code.
1000 AttributeOne AttributeTwo
1001 123456.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 456789.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 234567.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0
3456.0 1000 AttributeOne AttributeTwo
1001 345678.000000 AttributeFour
1002 1234.0 2345.0 3456.0 1003 1234.0 2345.0 3456.0 1004 1234.0 2345.0 3456.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
namespace list_question
{
public class someObject
{
//Line 1
public int Line1_ID;
public string Line1_Attribute1;
public string Line1_Attribute2;
//Line 2
public int Line2_ID;
public decimal Line2_Attribute3;
public string Line2_Attribute4;
//Line 3
public int Line3_ID;
public decimal data_pos1;
public decimal data_pos2;
public decimal data_pos3;
}
class Program
{
static void Main(string[] args)
{
string filepathRead = @"C:\Users\C121736\Desktop\SampleFile.txt";
List<someObject> somObList = new List<someObject>();
someObject obj = new someObject();
try
{
FileStream fs = new FileStream(filepathRead,
FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if ((line.Substring(0, 4) == "1000"))
{
string[] strArrFields1 = Regex.Split(line,
@"(.{6})" + "(.{14})" + "(.{20})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line1_ID =
int.Parse(strArrFields1[0].TrimEnd(' '));
obj_1.Line1_Attribute1 =
strArrFields1[1].TrimEnd(' ');
obj_1.Line1_Attribute2 =
strArrFields1[2].TrimEnd(' ');
somObList.Add(obj_1);
}
else if ((line.Substring(0, 4) == "1001"))
{
string[] strArrFields2 = Regex.Split(line,
@"(.{6})" + "(.{20})" + "(.{15})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line2_ID =
int.Parse(strArrFields2[0].TrimEnd(' '));
obj_1.Line2_Attribute3 =
decimal.Parse(strArrFields2[1].TrimEnd(' '));
obj_1.Line2_Attribute4 =
strArrFields2[2].TrimEnd(' ');
somObList.Add(obj_1);
}
else
{
string[] strArrFields3 = Regex.Split(line,
@"(.{6})" + "(.{7})" + "(.{7})" +
"(.{7})").Where(s =>
!string.IsNullOrEmpty(s)).ToArray();
someObject obj_1 = new someObject();
obj_1.Line3_ID =
int.Parse(strArrFields3[0].TrimEnd(' '));
obj_1.data_pos1 =
decimal.Parse(strArrFields3[1].TrimEnd(' '));
obj_1.data_pos2 =
decimal.Parse(strArrFields3[2].TrimEnd(' '));
obj_1.data_pos3 =
decimal.Parse(strArrFields3[3].TrimEnd(' '));
somObList.Add(obj_1);
}
}
}
catch (FileNotFoundException ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Program Exited");
Environment.Exit(99);
}
foreach (someObject o in somObList)
{
Console.WriteLine("{0},{1},{2}\n{3},{4},{5}\n{6},{7},{8},{9}",
o.Line1_ID, o.Line1_Attribute1, o.Line1_Attribute2,
o.Line2_ID, o.Line2_Attribute3, o.Line2_Attribute4,
o.Line3_ID, o.data_pos1, o.data_pos2, o.data_pos3);
}
somObList.Clear();
}
}
}
unable to get child element to fadein when hovering over parent element
unable to get child element to fadein when hovering over parent element
I am new to JQuery and am currently attempting to get a child element to
fade in to display product information when the user hovers over the
parent element.
this is as far as I've got with out luck:
jquery:
$('.overlay-wrap').hover(function(){
$('.product-overlay', this).fadeIn(2000, "swing");
},
$('.product-overlay', this).fadeOut("fast");
});
html:
<div class="overlay-wrap">
<div class="product-overlay"><a href="#">Name of the
product</a></div>
</div>
css:
.overlay-wrap{
position:relative;
border:1px solid red;
width:200px;
height:200px;
}
.product-overlay{
position:absolute;
bottom:0px;
left:0px;
background:#000;
opacity:0.5;
padding:5px;
width:100%;
display:none;
}
.product-overlay a{
font-size:12px;
line-height:20px;
}
Heres a simplified JSFiddle of what I have so far.
Why isn't the child element fading in when I hover over the parent element?
Thanks
I am new to JQuery and am currently attempting to get a child element to
fade in to display product information when the user hovers over the
parent element.
this is as far as I've got with out luck:
jquery:
$('.overlay-wrap').hover(function(){
$('.product-overlay', this).fadeIn(2000, "swing");
},
$('.product-overlay', this).fadeOut("fast");
});
html:
<div class="overlay-wrap">
<div class="product-overlay"><a href="#">Name of the
product</a></div>
</div>
css:
.overlay-wrap{
position:relative;
border:1px solid red;
width:200px;
height:200px;
}
.product-overlay{
position:absolute;
bottom:0px;
left:0px;
background:#000;
opacity:0.5;
padding:5px;
width:100%;
display:none;
}
.product-overlay a{
font-size:12px;
line-height:20px;
}
Heres a simplified JSFiddle of what I have so far.
Why isn't the child element fading in when I hover over the parent element?
Thanks
Avoiding validation checks while saving an object in Datamapper
Avoiding validation checks while saving an object in Datamapper
I am new to Ruby on Rails and Datamapper. I have created a Rails
application where I have used two models A and B, where there are some
validation checks in A. But in an application I want to save A by avoiding
a validation check. Is that possible in datamapper?
I am new to Ruby on Rails and Datamapper. I have created a Rails
application where I have used two models A and B, where there are some
validation checks in A. But in an application I want to save A by avoiding
a validation check. Is that possible in datamapper?
Application Kills itself after few hours , Dont want to use startForeground
Application Kills itself after few hours , Dont want to use startForeground
I am using a Service for fetching Coordinates from GPS as well as from
Network
I am Using Alarm Manager to activate the Service every 2 Minute like
Intent myIntent=new Intent(Main.this,ServiceNew.class);
PendingIntent
pendingIntent=PendingIntent.getService(OkayaMain.this,0,myIntent,0);
AlarmManager
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MINUTE,0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),UPDATE_INTERVAL,pendingIntent);
It activates every 2 min But after some time it kill or OS Make it to kill
, I Dont Want to use Foreground Services
my ServiceClass is ServiceNew.class
public class ServiceNew extends Service{
public void onCreate(){
super.onCreate();
try{
fnPushLocationCoordinates();
// This will save the Coordinates after getting through Location MAnager
}
catch(Exception ex){
response=ex.toString();
return;
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//fnPushLocation();
return START_STICKY;
}
@Override
public IBinder onBind(Intent arg0){
return null;
}
I dont want application to be killed , do we have any solution for this
Please Help ,Thanks in advance
I am using a Service for fetching Coordinates from GPS as well as from
Network
I am Using Alarm Manager to activate the Service every 2 Minute like
Intent myIntent=new Intent(Main.this,ServiceNew.class);
PendingIntent
pendingIntent=PendingIntent.getService(OkayaMain.this,0,myIntent,0);
AlarmManager
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MINUTE,0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),UPDATE_INTERVAL,pendingIntent);
It activates every 2 min But after some time it kill or OS Make it to kill
, I Dont Want to use Foreground Services
my ServiceClass is ServiceNew.class
public class ServiceNew extends Service{
public void onCreate(){
super.onCreate();
try{
fnPushLocationCoordinates();
// This will save the Coordinates after getting through Location MAnager
}
catch(Exception ex){
response=ex.toString();
return;
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//fnPushLocation();
return START_STICKY;
}
@Override
public IBinder onBind(Intent arg0){
return null;
}
I dont want application to be killed , do we have any solution for this
Please Help ,Thanks in advance
Thursday, 12 September 2013
Chrome: jQuery Height not Setting on First Load
Chrome: jQuery Height not Setting on First Load
I've encountered a strange error ONLY in Chrome where height will not
properly set on load when being set via jQuery. The height will set find
on load when the browser is refreshed, but when you open a new tab or
first navigate to the page, the height is not properly set:
wrong:
right:
Here is my code:
jQuery(document).ready(function ($) {
var $grid = $(".tile-grid"),
$homeGrid = $(".home"),
$boxes = $grid.find("section"),
$window = $(window);
function resizeBoxes() {
var boxWidth = $boxes.first().not(".active").outerWidth();
$boxes.css("height", boxWidth);
}
function main() {
$window.on("resize", function() {
resizeBoxes();
});
resizeBoxes();
}
main();
});
Upon further investigation, I find that the function has been executed,
but that each box has been set to have a height of 9px, which seems to
indicate that an animation may be responsible for this. But when I remove
all animations, I still get the same result...
How do I fix this?
I've encountered a strange error ONLY in Chrome where height will not
properly set on load when being set via jQuery. The height will set find
on load when the browser is refreshed, but when you open a new tab or
first navigate to the page, the height is not properly set:
wrong:
right:
Here is my code:
jQuery(document).ready(function ($) {
var $grid = $(".tile-grid"),
$homeGrid = $(".home"),
$boxes = $grid.find("section"),
$window = $(window);
function resizeBoxes() {
var boxWidth = $boxes.first().not(".active").outerWidth();
$boxes.css("height", boxWidth);
}
function main() {
$window.on("resize", function() {
resizeBoxes();
});
resizeBoxes();
}
main();
});
Upon further investigation, I find that the function has been executed,
but that each box has been set to have a height of 9px, which seems to
indicate that an animation may be responsible for this. But when I remove
all animations, I still get the same result...
How do I fix this?
How do I make a separate menu in my Visual Studio Integration Project?
How do I make a separate menu in my Visual Studio Integration Project?
How do I make a separate menu in my Visual Studio Integration Project?
Every menu I create gets placed under "Tools" in VS2010. How do I get my
own menu group in VS and then how do I add items underneath that menu
group?
How do I make a separate menu in my Visual Studio Integration Project?
Every menu I create gets placed under "Tools" in VS2010. How do I get my
own menu group in VS and then how do I add items underneath that menu
group?
Unsure of for loop
Unsure of for loop
Not sure what I'm doing wrong here. Any help would be appreciated. When I
enter a DNA sequence that contains a bad variable (like Z) I keep getting
a return True. Can someone point out why?
Thanks
def is_valid_sequence(dna):
""" (str) -> bool
>>> is_valid_sequence('ATCG')
True
>>> is_valid_sequence('AZT')
False
>>> is_valid_sequence('atcg')
False
Returns a boolean result based on whether dna is a valid
dna sequence.
"""
for char in dna:
if char in "TCGA":
return True
else:
return False
Not sure what I'm doing wrong here. Any help would be appreciated. When I
enter a DNA sequence that contains a bad variable (like Z) I keep getting
a return True. Can someone point out why?
Thanks
def is_valid_sequence(dna):
""" (str) -> bool
>>> is_valid_sequence('ATCG')
True
>>> is_valid_sequence('AZT')
False
>>> is_valid_sequence('atcg')
False
Returns a boolean result based on whether dna is a valid
dna sequence.
"""
for char in dna:
if char in "TCGA":
return True
else:
return False
Storyboard returns new instance with old property instances iphone
Storyboard returns new instance with old property instances iphone
So i was working on storyboard and i ran into a corner. I created an int
array int[3] and i set values to 0. Then i changed first value on first
page, and second value on another page. I thought both pages has same
instance of int array but i noticed that the array has same values in both
views and same memory address.
So i made stuff more complicated. I created an NSMutableArray, on
viewDidLoad i set this array to nil, then i alloc and init it. I then add
one object to it. Next page - new array! New memory address, no elements.
So i add one element to this array - bam! Address is now the same as in
old view and there are two elements (old one and new one).
Yes i did release that array on dealloc on old view.
So i created static int, and incremented it in viewDidLoad
static int i = 0; i++;
Every time i open new page, with different memory address i get integer
incremented by one and printed out. This happens on empty project with
nothing altered.
My question: Why do i read in apple docs that storyboard creates new and
unique instance of views and then i see this "old value issue"?
UPDATE
Okay so i declare my array like this:
@property (retain, nonatomic) NSMutableArray *destroyedObjects;
Dealloc method:
- (void)dealloc
{
[_destroyedObjects release];
_destroyedObjects = nil;
[super dealloc];
}
Initialisation of the view itself:
- (DataViewController *)viewControllerAtIndex:(NSUInteger)index
storyboard:(UIStoryboard *)storyboard
{
// Return the data view controller for the given index.
if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
return nil;
}
// Create a new view controller and pass suitable data.
DataViewController *dataViewController = [storyboard
instantiateViewControllerWithIdentifier:@"DataViewController"];
return dataViewController;
}
View did load of this controller:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_destroyedObjects = nil;
_destroyedObjects = [NSMutableArray new];
}
Somwhere within the code i do this (this is done as soon as button in xib
is pressed):
[_destroyedObjects addObject:[NSNumber numberWithInt:[objectView
typeInteger]]];
How i see that values are bad? This is log when i init the view (NSLog
self) and when i set the value (log self and array):
2013-09-12 17:36:02.334 TAApp[29041:c07] <DataViewController: 0x9347fa0>
2013-09-12 17:36:04.731 TAApp[29041:c07] <DataViewController: 0x9336cd0>
2013-09-12 17:36:04.731 TAApp[29041:c07] (
0,
1
)
2013-09-12 17:36:05.671 TAApp[29041:c07] <DataViewController: 0x912bd40>
2013-09-12 17:36:08.100 TAApp[29041:c07] <DataViewController: 0x9336cd0>
2013-09-12 17:36:08.101 TAApp[29041:c07] (
0,
1,
0
)
Both prints made on different pages.
So i was working on storyboard and i ran into a corner. I created an int
array int[3] and i set values to 0. Then i changed first value on first
page, and second value on another page. I thought both pages has same
instance of int array but i noticed that the array has same values in both
views and same memory address.
So i made stuff more complicated. I created an NSMutableArray, on
viewDidLoad i set this array to nil, then i alloc and init it. I then add
one object to it. Next page - new array! New memory address, no elements.
So i add one element to this array - bam! Address is now the same as in
old view and there are two elements (old one and new one).
Yes i did release that array on dealloc on old view.
So i created static int, and incremented it in viewDidLoad
static int i = 0; i++;
Every time i open new page, with different memory address i get integer
incremented by one and printed out. This happens on empty project with
nothing altered.
My question: Why do i read in apple docs that storyboard creates new and
unique instance of views and then i see this "old value issue"?
UPDATE
Okay so i declare my array like this:
@property (retain, nonatomic) NSMutableArray *destroyedObjects;
Dealloc method:
- (void)dealloc
{
[_destroyedObjects release];
_destroyedObjects = nil;
[super dealloc];
}
Initialisation of the view itself:
- (DataViewController *)viewControllerAtIndex:(NSUInteger)index
storyboard:(UIStoryboard *)storyboard
{
// Return the data view controller for the given index.
if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
return nil;
}
// Create a new view controller and pass suitable data.
DataViewController *dataViewController = [storyboard
instantiateViewControllerWithIdentifier:@"DataViewController"];
return dataViewController;
}
View did load of this controller:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_destroyedObjects = nil;
_destroyedObjects = [NSMutableArray new];
}
Somwhere within the code i do this (this is done as soon as button in xib
is pressed):
[_destroyedObjects addObject:[NSNumber numberWithInt:[objectView
typeInteger]]];
How i see that values are bad? This is log when i init the view (NSLog
self) and when i set the value (log self and array):
2013-09-12 17:36:02.334 TAApp[29041:c07] <DataViewController: 0x9347fa0>
2013-09-12 17:36:04.731 TAApp[29041:c07] <DataViewController: 0x9336cd0>
2013-09-12 17:36:04.731 TAApp[29041:c07] (
0,
1
)
2013-09-12 17:36:05.671 TAApp[29041:c07] <DataViewController: 0x912bd40>
2013-09-12 17:36:08.100 TAApp[29041:c07] <DataViewController: 0x9336cd0>
2013-09-12 17:36:08.101 TAApp[29041:c07] (
0,
1,
0
)
Both prints made on different pages.
Efficient way to merge multiple large XML files on android
Efficient way to merge multiple large XML files on android
Use Case: Think of an application that performs a daily backup of your
call log or messages and stores it into an XML file.
Now, I want to implement the ability to merge two or more files and create
one XML file. Some of the entries may be duplicate, some added, some
deleted.
I could create a Map and put all entries into it with "id" being the key
(which will be unique for each row). But this approach may cause memory
issues if the number of rows run into several thousands.
Can anybody suggest a better way of implementing this merge feature?
Use Case: Think of an application that performs a daily backup of your
call log or messages and stores it into an XML file.
Now, I want to implement the ability to merge two or more files and create
one XML file. Some of the entries may be duplicate, some added, some
deleted.
I could create a Map and put all entries into it with "id" being the key
(which will be unique for each row). But this approach may cause memory
issues if the number of rows run into several thousands.
Can anybody suggest a better way of implementing this merge feature?
Wednesday, 11 September 2013
overriding Cart.php class doesn't work in prestashop
overriding Cart.php class doesn't work in prestashop
I am try to override the default Cart.php class. I put my Cart.php in
override/classes/Cart.php. but It doesn't make any changes in the output.
<?php
class Cart extends CartCore
{
print_r("sample test override");
die();
}
?>
my cart.php code is like above. Can anyone help me, is there any other
additional steps needed to override?
I am try to override the default Cart.php class. I put my Cart.php in
override/classes/Cart.php. but It doesn't make any changes in the output.
<?php
class Cart extends CartCore
{
print_r("sample test override");
die();
}
?>
my cart.php code is like above. Can anyone help me, is there any other
additional steps needed to override?
How to load image into bootstrap modal with javascript
How to load image into bootstrap modal with javascript
My setup is 4 links (below). I want each link to open myModal, but
depending on which link gets clicked, a different image file should load
in the modal. I got it working for one of the links.
<li><a href="#myModal" data-toggle="modal">6 Teams</a></li>
<li><a href="#">5 Teams</a></li>
<li><a href="#">4 Teams</a></li>
<li><a href="#">3 Teams</a></li>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
</div>
<div class="modal-body">
<img src="/images/brackets/6teamDouble1.jpg">
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
How do I get this to work for each link without building a separate modal
for each one?
My setup is 4 links (below). I want each link to open myModal, but
depending on which link gets clicked, a different image file should load
in the modal. I got it working for one of the links.
<li><a href="#myModal" data-toggle="modal">6 Teams</a></li>
<li><a href="#">5 Teams</a></li>
<li><a href="#">4 Teams</a></li>
<li><a href="#">3 Teams</a></li>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
</div>
<div class="modal-body">
<img src="/images/brackets/6teamDouble1.jpg">
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
How do I get this to work for each link without building a separate modal
for each one?
Retreiving Native Code Architecture from an Android App
Retreiving Native Code Architecture from an Android App
I'm working on an app which determines the native code architecture and
native libraries used by the apps installed on the device. Its similar to
running the following command.
aapt dump badging <file.apk location>
The package manager doesn't provide information about the native code like
this one or the native shared libraries. I can retrieve the native shared
libraries that the target app uses with the following code:
try {
Set<String> libs = new HashSet<String>();
String mapsFile = "/proc/" + android.os.Process.myPid() + "/maps";
BufferedReader reader = new BufferedReader(new FileReader(mapsFile));
String line;
while ((line = reader.readLine()) != null) {
if (line.endsWith(".so")) {
int n = line.lastIndexOf(" ");
libs.add(line.substring(n + 1));
}
}
Log.d("Ldd", libs.size() + " libraries:");
for (String lib : libs) {
Log.d("Ldd", lib);
}
} catch (FileNotFoundException e) {
// Do some error handling...
} catch (IOException e) {
// Do some error handling...
}
All I require is the native code architecture used by the app package. I
want to determine the compatible native code architecture from app
package. Any help?
I'm working on an app which determines the native code architecture and
native libraries used by the apps installed on the device. Its similar to
running the following command.
aapt dump badging <file.apk location>
The package manager doesn't provide information about the native code like
this one or the native shared libraries. I can retrieve the native shared
libraries that the target app uses with the following code:
try {
Set<String> libs = new HashSet<String>();
String mapsFile = "/proc/" + android.os.Process.myPid() + "/maps";
BufferedReader reader = new BufferedReader(new FileReader(mapsFile));
String line;
while ((line = reader.readLine()) != null) {
if (line.endsWith(".so")) {
int n = line.lastIndexOf(" ");
libs.add(line.substring(n + 1));
}
}
Log.d("Ldd", libs.size() + " libraries:");
for (String lib : libs) {
Log.d("Ldd", lib);
}
} catch (FileNotFoundException e) {
// Do some error handling...
} catch (IOException e) {
// Do some error handling...
}
All I require is the native code architecture used by the app package. I
want to determine the compatible native code architecture from app
package. Any help?
Detect number of times mousewheel is scrolled
Detect number of times mousewheel is scrolled
I'm trying to achieve an effect like the one here. I want to perform an
action each time the scroll wheel is scrolled, regardless of how much the
user tries to scroll. How would I count the number of times the user tries
to scroll? I've been playing around with $(window).on('scroll'.... Thanks
I'm trying to achieve an effect like the one here. I want to perform an
action each time the scroll wheel is scrolled, regardless of how much the
user tries to scroll. How would I count the number of times the user tries
to scroll? I've been playing around with $(window).on('scroll'.... Thanks
Why is my ASCII char to int conversion failing?
Why is my ASCII char to int conversion failing?
According to the chart here:
http://www.idautomation.com/barcode-faq/code-128/
This character:
Ë
equates to the value 103.
Yet this code:
string barcode = textBoxRawCode128.Text.Trim();
. . .
int runningTotal = ConvertToASCIIInt(barCode[0]);
. . .
private int ConvertToASCIIInt(char valToConvertToASCII)
{
const int ASCII_ADJUSTMENT_VAL = 32;
return valToConvertToASCII - ASCII_ADJUSTMENT_VAL;
}
...when the value in the textbox and thus of barcode is "ËTry another
string.", thus where barcode[0] is "Ë", returns a value of 171 instead of
103...???
And according to this chart: http://www.adams1.com/128table.html, the
value corresponding to 103 is ‡, but when I set barCode to "‡Try another
string.", the returned value is 8193...??? Curiouser and curiouser...
Note: A related/preliminary post is Is this code for calculating Code128
barcode check digits correct?
According to the chart here:
http://www.idautomation.com/barcode-faq/code-128/
This character:
Ë
equates to the value 103.
Yet this code:
string barcode = textBoxRawCode128.Text.Trim();
. . .
int runningTotal = ConvertToASCIIInt(barCode[0]);
. . .
private int ConvertToASCIIInt(char valToConvertToASCII)
{
const int ASCII_ADJUSTMENT_VAL = 32;
return valToConvertToASCII - ASCII_ADJUSTMENT_VAL;
}
...when the value in the textbox and thus of barcode is "ËTry another
string.", thus where barcode[0] is "Ë", returns a value of 171 instead of
103...???
And according to this chart: http://www.adams1.com/128table.html, the
value corresponding to 103 is ‡, but when I set barCode to "‡Try another
string.", the returned value is 8193...??? Curiouser and curiouser...
Note: A related/preliminary post is Is this code for calculating Code128
barcode check digits correct?
Return child class from parent's static method
Return child class from parent's static method
I just learned about this fancy new feature of PHP 5.4. JsonSerializable!
This is perfect for my app.
My app uses DateTime objects, and when I json_encode them, I get the
following (by running json_encode([new DateTime])):
[{"date":"2013-09-11 15:39:22","timezone_type":3,"timezone":"UTC"}]
Depending on what timezone_type is, the timezone value may be different. I
haven't found a good way to parse this object in JavaScript.
So, I decided to create my own DateTime class, and have it serialize to
JSON how I wanted.
class SerialDateTime extends DateTime implements JsonSerializable{
public function jsonSerialize(){
return ['timestamp' => $this->getTimestamp()];
}
}
When I now run json_encode([new SerialDateTime]), I get this:
[{"timestamp":1378914190}]
That's much easier to parse in JavaScript.
So, I figured this was a fine solution, but I discovered a problem. Static
methods! SerialDateTime::createFromFormat returns a DateTime object!
If I do: json_encode([SerialDateTime::createFromFormat('m/d/Y',
'10/31/2011')]), I get:
[{"date":"2011-10-31 15:46:07","timezone_type":3,"timezone":"UTC"}]
Why is this happening? Why doesn't SerialDateTime::createFromFormat return
me a SerialDateTime object?!
How can I fix this, or do I need to override all the static methods from
DateTime in SerialDateTime? If I do that, how would I even make a new
SerialDateTime from the createFromFormat method? How can I "cast" a
DateTime object to SerialDateTime?
I thought of a workaround, but there's got to be a better way:
public static function createFromFormat($f, $t, $tz=NULL){
$dateTime = call_user_func(
array('SerialDateTime', 'parent::createFromFormat'),
$f, $t, $tz
);
$ret = new self();
return $ret->setTimestamp($dateTime->getTimestamp());
}
Could I maybe use __callStatic and return
call_user_func_array(array(__CLASS__ , 'parent::'.__FUNCTION__),
func_get_args()); or something?
I just learned about this fancy new feature of PHP 5.4. JsonSerializable!
This is perfect for my app.
My app uses DateTime objects, and when I json_encode them, I get the
following (by running json_encode([new DateTime])):
[{"date":"2013-09-11 15:39:22","timezone_type":3,"timezone":"UTC"}]
Depending on what timezone_type is, the timezone value may be different. I
haven't found a good way to parse this object in JavaScript.
So, I decided to create my own DateTime class, and have it serialize to
JSON how I wanted.
class SerialDateTime extends DateTime implements JsonSerializable{
public function jsonSerialize(){
return ['timestamp' => $this->getTimestamp()];
}
}
When I now run json_encode([new SerialDateTime]), I get this:
[{"timestamp":1378914190}]
That's much easier to parse in JavaScript.
So, I figured this was a fine solution, but I discovered a problem. Static
methods! SerialDateTime::createFromFormat returns a DateTime object!
If I do: json_encode([SerialDateTime::createFromFormat('m/d/Y',
'10/31/2011')]), I get:
[{"date":"2011-10-31 15:46:07","timezone_type":3,"timezone":"UTC"}]
Why is this happening? Why doesn't SerialDateTime::createFromFormat return
me a SerialDateTime object?!
How can I fix this, or do I need to override all the static methods from
DateTime in SerialDateTime? If I do that, how would I even make a new
SerialDateTime from the createFromFormat method? How can I "cast" a
DateTime object to SerialDateTime?
I thought of a workaround, but there's got to be a better way:
public static function createFromFormat($f, $t, $tz=NULL){
$dateTime = call_user_func(
array('SerialDateTime', 'parent::createFromFormat'),
$f, $t, $tz
);
$ret = new self();
return $ret->setTimestamp($dateTime->getTimestamp());
}
Could I maybe use __callStatic and return
call_user_func_array(array(__CLASS__ , 'parent::'.__FUNCTION__),
func_get_args()); or something?
Line-height won't work
Line-height won't work
I've got a problem that's bothering me. The line-height seems to be based
on the inherit by a previous font-size.
Here's a link to the site
I want the result to be:
Now it's like this:
Sorry bout' not posting the entire code. Any ideas?
I've got a problem that's bothering me. The line-height seems to be based
on the inherit by a previous font-size.
Here's a link to the site
I want the result to be:
Now it's like this:
Sorry bout' not posting the entire code. Any ideas?
Visual Studio 2012 install hang SQL server 2012 transact
Visual Studio 2012 install hang SQL server 2012 transact
I'm trying to install VS2012 Ultimate during the install we had a power
failure which caused pc to restart. After log-on the installer started
again but it hangs on
Microsoft SQL Server 2012 Transact-SQL ScriptDom
Next I tried to cancel the install but this just says stopping install
Any ideas how to fix the installer or clean the installer to start from
the beginning?
I'm trying to install VS2012 Ultimate during the install we had a power
failure which caused pc to restart. After log-on the installer started
again but it hangs on
Microsoft SQL Server 2012 Transact-SQL ScriptDom
Next I tried to cancel the install but this just says stopping install
Any ideas how to fix the installer or clean the installer to start from
the beginning?
Consequences of the PermGen suppression
Consequences of the PermGen suppression
The next java release comes with the removal of the permanent generation
space. What are the consequences a java developer should know ?
The next java release comes with the removal of the permanent generation
space. What are the consequences a java developer should know ?
Tuesday, 10 September 2013
close slide panel on angular js
close slide panel on angular js
please help to fix script
http://jsfiddle.net/M4pXU/
when you click on the red field is displayed to the panel. ok
I need that when you click on the yellow area is a concealed panel. thus
if a user clicks on a green field, nothing happens
html:
<div class="body" ng-app="moduleSlidePanel"
ng-controller="controllerSlidePanel" ng-click="shoooooo = false">
<div class="wrap_news">
<div class="slide_panel" ng-class="{'showPanel':sho}"
ng-click="sho = true">
<div class="slide_panel_inner">
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
</div>
</div>
</div>
</div>
css:
.body{
height:100%;
background: yellow;
font: 14px helvetica, arial, sans-serif;
}
html, body, div, h1, h2, h3, h4, h5, h6, a, a img, p, ul, ol, li, span,
fieldset , form, dl, dd, dt, table, tr, td, img{
border: none;
margin: 0;
outline: none;
padding: 0;
}
html{
height:100%;
}
body{
height:100%;
background: yellow;
font: 14px helvetica, arial, sans-serif;
}
/*******************************************************************************************************************************
2. fonts */
/******************************************************************************************************************************
3. layout */
/*******************************************************************************************************************************
5.1 */
.wrap_news{
position: relative;
width: 100%;
margin: 0 auto;
height: 500px;
}
.wrap_news .slide_panel{
position: absolute;
left: -200px;
top: 100px;
background: red;
padding-right: 30px;
width: 200px;
overflow: hidden;
padding-right: 30px;
-webkit-transition: 1s linear all; /* Safari/Chrome */
-moz-transition: 1s linear all; /* Firefox */
-ms-transition: 1s linear all; /* IE10 */
-o-transition: 1s linear all; /* Opera */
transition: 1s linear all; /* Future Browsers */
}
.slide_panel_inner{
background: lime;
}
.wrap_news .slide_panel.showPanel{
left: 0;
right: auto;
}
please help to fix script
http://jsfiddle.net/M4pXU/
when you click on the red field is displayed to the panel. ok
I need that when you click on the yellow area is a concealed panel. thus
if a user clicks on a green field, nothing happens
html:
<div class="body" ng-app="moduleSlidePanel"
ng-controller="controllerSlidePanel" ng-click="shoooooo = false">
<div class="wrap_news">
<div class="slide_panel" ng-class="{'showPanel':sho}"
ng-click="sho = true">
<div class="slide_panel_inner">
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
qweeeeeeeeeeeeeeeeeeee eeety<br />
</div>
</div>
</div>
</div>
css:
.body{
height:100%;
background: yellow;
font: 14px helvetica, arial, sans-serif;
}
html, body, div, h1, h2, h3, h4, h5, h6, a, a img, p, ul, ol, li, span,
fieldset , form, dl, dd, dt, table, tr, td, img{
border: none;
margin: 0;
outline: none;
padding: 0;
}
html{
height:100%;
}
body{
height:100%;
background: yellow;
font: 14px helvetica, arial, sans-serif;
}
/*******************************************************************************************************************************
2. fonts */
/******************************************************************************************************************************
3. layout */
/*******************************************************************************************************************************
5.1 */
.wrap_news{
position: relative;
width: 100%;
margin: 0 auto;
height: 500px;
}
.wrap_news .slide_panel{
position: absolute;
left: -200px;
top: 100px;
background: red;
padding-right: 30px;
width: 200px;
overflow: hidden;
padding-right: 30px;
-webkit-transition: 1s linear all; /* Safari/Chrome */
-moz-transition: 1s linear all; /* Firefox */
-ms-transition: 1s linear all; /* IE10 */
-o-transition: 1s linear all; /* Opera */
transition: 1s linear all; /* Future Browsers */
}
.slide_panel_inner{
background: lime;
}
.wrap_news .slide_panel.showPanel{
left: 0;
right: auto;
}
Deterministic python generator for K disparate M-sized subsets of a set
Deterministic python generator for K disparate M-sized subsets of a set
I'm looking for an efficient way to generate many M-sized subsets from a
set S, of size N.
Ideally I would like to generate all of these, but because I'm using them
for other computations, this becomes infeasible.
Instead, I would like to generate K disparate subsets of S, such that the
K chosen subsets minimize the sum of the size of the all pairwise
intersections between the K subsets.
In other words If I have K subsets And I take the pairwise intersection of
all of those subsets. And then I sum the size of all of those sets
together. I get as low of a number as I can.
Basically, I want these subsets to be as "far away" from each other was
possible. I've been trying to think of how I would go about doing this,
but I'm drawing a blank.
To simulate it in the meantime I've written this function
def subset_split(full_set, M, K):
np.random.seed(0) # repeatibility
seen = set([])
subset_list = []
for kx in xrange(K):
np.random.shuffle(full_set)
failsafe = 0
while True:
np.random.shuffle(full_set)
subset = tuple(full_set[0:M])
if not subset in seen:
seen.add(subset)
subset_list.append(subset)
break
failsafe += 1
if failsafe > 100:
break
return subset_list
which just generates K random subsets that haven't been seen before. But
this isn't exactly what I want, because I want those K subsets to be
repeatable and to not accidentally be close to each if they don't have to
be.
I'm looking for an efficient way to generate many M-sized subsets from a
set S, of size N.
Ideally I would like to generate all of these, but because I'm using them
for other computations, this becomes infeasible.
Instead, I would like to generate K disparate subsets of S, such that the
K chosen subsets minimize the sum of the size of the all pairwise
intersections between the K subsets.
In other words If I have K subsets And I take the pairwise intersection of
all of those subsets. And then I sum the size of all of those sets
together. I get as low of a number as I can.
Basically, I want these subsets to be as "far away" from each other was
possible. I've been trying to think of how I would go about doing this,
but I'm drawing a blank.
To simulate it in the meantime I've written this function
def subset_split(full_set, M, K):
np.random.seed(0) # repeatibility
seen = set([])
subset_list = []
for kx in xrange(K):
np.random.shuffle(full_set)
failsafe = 0
while True:
np.random.shuffle(full_set)
subset = tuple(full_set[0:M])
if not subset in seen:
seen.add(subset)
subset_list.append(subset)
break
failsafe += 1
if failsafe > 100:
break
return subset_list
which just generates K random subsets that haven't been seen before. But
this isn't exactly what I want, because I want those K subsets to be
repeatable and to not accidentally be close to each if they don't have to
be.
Calling WCF Service from JavaScript
Calling WCF Service from JavaScript
I have a WCF webservice developed with .NET 4.0 which I need to be called
by a Javascript client. I have been searching online for the best binding
to use to make this possible. Most answers seems to point towards webhttp,
but I am concerned as this is one of the lest secure bindings. What is the
best way to configure this?
I have a WCF webservice developed with .NET 4.0 which I need to be called
by a Javascript client. I have been searching online for the best binding
to use to make this possible. Most answers seems to point towards webhttp,
but I am concerned as this is one of the lest secure bindings. What is the
best way to configure this?
EmberJS, how to query the model with getter functions?
EmberJS, how to query the model with getter functions?
I don't know if I asked correctly, but instead of having the collection of
data, I would like to compute the data based on parameter. Something like:
var date = new Date();
var events = model.getEvents(date);
{{#each event in events}}
event
{{/each}}
The difference being here that getEvents does both the fetching from
server, plus local computation and transformation before returning the
collection.
I don't know if I asked correctly, but instead of having the collection of
data, I would like to compute the data based on parameter. Something like:
var date = new Date();
var events = model.getEvents(date);
{{#each event in events}}
event
{{/each}}
The difference being here that getEvents does both the fetching from
server, plus local computation and transformation before returning the
collection.
psql telling me "database does not exist" in some places, recognizing it in others
psql telling me "database does not exist" in some places, recognizing it
in others
I'm trying to run these commands from this tutorial
(http://jamiecook.wordpress.com/2011/11/24/setting-up-postgresql-postgis-for-rails-on-ubuntu/)
sudo su - postgres
createdb -E UTF8 template_postgis # Create the template spatial database.
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
psql -d osm -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
psql -d osm -f
/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
cat <<EOS | psql -d template_postgis
UPDATE pg_database SET datistemplate = TRUE WHERE datname =
'template_postgis';
REVOKE ALL ON SCHEMA public FROM public;
GRANT USAGE ON SCHEMA public TO public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.geometry_columns TO
PUBLIC;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.spatial_ref_sys TO
PUBLIC;
GRANT ALL ON geometry_columns TO PUBLIC;
GRANT ALL ON geography_columns TO PUBLIC;
GRANT ALL ON spatial_ref_sys TO PUBLIC;
VACUUM FULL FREEZE;
EOS
and am getting the error:
ERROR: relation "sample_postgis_db" does not exist
LINE 1: UPDATE sample_postgis_db SET datistemplate=TRUE WHERE datnam...
But it certainly does exist:
psql -d postgres
\list
#=>
...
sample_postgis_db | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
...
I can login to it:
psql -d sample_postgis_db
but even when I run that UPDATE line inside of the db's psql, it still
doesn't recognize itself.
sample_postgis_db=# UPDATE sample_postgis_db SET datistemplate=TRUE WHERE
datname = "template_postgis";
ERROR: relation "sample_postgis_db" does not exist
LINE 1: UPDATE sample_postgis_db SET datistemplate=TRUE WHERE datnam...
in others
I'm trying to run these commands from this tutorial
(http://jamiecook.wordpress.com/2011/11/24/setting-up-postgresql-postgis-for-rails-on-ubuntu/)
sudo su - postgres
createdb -E UTF8 template_postgis # Create the template spatial database.
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
psql -d osm -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
psql -d osm -f
/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
cat <<EOS | psql -d template_postgis
UPDATE pg_database SET datistemplate = TRUE WHERE datname =
'template_postgis';
REVOKE ALL ON SCHEMA public FROM public;
GRANT USAGE ON SCHEMA public TO public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.geometry_columns TO
PUBLIC;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.spatial_ref_sys TO
PUBLIC;
GRANT ALL ON geometry_columns TO PUBLIC;
GRANT ALL ON geography_columns TO PUBLIC;
GRANT ALL ON spatial_ref_sys TO PUBLIC;
VACUUM FULL FREEZE;
EOS
and am getting the error:
ERROR: relation "sample_postgis_db" does not exist
LINE 1: UPDATE sample_postgis_db SET datistemplate=TRUE WHERE datnam...
But it certainly does exist:
psql -d postgres
\list
#=>
...
sample_postgis_db | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
...
I can login to it:
psql -d sample_postgis_db
but even when I run that UPDATE line inside of the db's psql, it still
doesn't recognize itself.
sample_postgis_db=# UPDATE sample_postgis_db SET datistemplate=TRUE WHERE
datname = "template_postgis";
ERROR: relation "sample_postgis_db" does not exist
LINE 1: UPDATE sample_postgis_db SET datistemplate=TRUE WHERE datnam...
Subscribe to:
Comments (Atom)