problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Variable not updated after lateinit declaraton, unable to return : OnCreateView Function
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
val view1 = inflater?.inflate(R.layout.fragment_home, container, false)
val recyclerview = view1!!.findViewById<RecyclerView>(R.id.recycler_view)
recyclerview.layoutManager = LinearLayoutManager(this.activity)
//val name3: Array<Articles> =
recyclerview.adapter = CustomAdaptor(fetchJson())
return view1
}
Fetchjson function
fun fetchJson(): Array<Articles> {
println("Attempting to fetch JSON")
val url1 = "https://go-api-api.herokuapp.com/"
//var a1 = Articles(1, "rsdfd", "fdsadfd", 2345, 3)
lateinit var name2: Array<Articles> //Initialized name2
val request = Request.Builder().url(url1).build()
val client = OkHttpClient()
client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call?, response: Response?) {
val body = response?.body()?.string()
println(body)
val gson = GsonBuilder().create()
try {
name2 = gson.fromJson(body, Array<Articles>::class.java) //Updating value of name2
}
catch (e: Exception){
print("Error roroorirorr")
print(e)
}
}
override fun onFailure(call: Call?, e: IOException?) {
println("Faild to execute request")
}
})
return name2 //returning name2
}
The `CustomAdaptor` takes the input `Article` class. I have created a late initialized variable name2. In fetchjson, value of json does not get updated.
#error shown by Android Studio.
>kotlin.UninitializedPropertyAccessException: lateinit property name2 has not been initialized
How should I declare the variable, so as to get it updated ?
| 0debug
|
Anti-Forgery Token was meant for a different claims-based user : <p>I am working on a logout feature in the application we are using ASP.NET Identity login. I can login successfully but when I logout and then try to login again I get the following message: </p>
<pre><code>The provided anti-forgery token was meant for a different claims-based user than the current user.
</code></pre>
<p>Here is my logout code: </p>
<pre><code> public ActionResult Logout()
{
SignInManager.Logout();
return View("Index");
}
**SignInManager.cs**
public void Logout()
{
AuthenticationManager.SignOut();
}
</code></pre>
<p>After the user press the logout button he is taken to the login screen. The url still says "<a href="http://localhost:8544/Login/Logout" rel="noreferrer">http://localhost:8544/Login/Logout</a>". Since we are on the login screen maybe it should just say "<a href="http://localhost:8544/Login" rel="noreferrer">http://localhost:8544/Login</a>". </p>
| 0debug
|
Combinations with X unique numbers in Python : <p>I want to find combinations of 12 digits of numbers from 1-225 and then find which of these combinations contain only 6 unique numbers (eg: 123456123456).</p>
<p>Now i’ve managed to find the Itertools library for combinatorics but i can’t seem to figure out how to extract the ones with only 6 unique digits.</p>
<p>Any help would be appericiated.</p>
| 0debug
|
Is scoping broken in VBA? : <p>Say you have this code in a module called <code>Module1</code>:</p>
<pre><code>Option Explicit
Private Type TSomething
Foo As Integer
Bar As Integer
End Type
Public Something As TSomething
</code></pre>
<p>In equivalent C# code if you made the <code>Something</code> field <code>public</code>, the code would no longer compile, because of <em>inconsistent accessibility</em> - the <em>type</em> of the field being less accessible than the field itself. Which makes sense.</p>
<p>However in VBA you could have this code in <code>Module2</code>:</p>
<pre><code>Sub DoSomething()
Module1.Something.Bar = 42
Debug.Print Module1.Something.Bar
End Sub
</code></pre>
<p>And you get IntelliSense while typing it, and it compiles, and it runs, and it outputs <code>42</code>.</p>
<p>Why? How does it even work, from a COM standpoint? Is it part of the language specs?</p>
| 0debug
|
How to use the MSDN : <p>This might seem like a stupid question, but the documentation is either bad or I'm missing something i didn't read. Everytime i refer to the MSDN for c++ related questions I'm always confused. Like the SetComputerName function. I looked up the MSDN and didn't know how to use it because i was completely clueless. Can anyone teach me how to read something like this, also if you could explain it in laymens terms im not very good at c++ thanks! </p>
<pre><code>BOOL WINAPI SetComputerName(
_In_ LPCTSTR lpComputerName
);
</code></pre>
| 0debug
|
static void ffm_set_write_index(AVFormatContext *s, int64_t pos,
int64_t file_size)
{
FFMContext *ffm = s->priv_data;
ffm->write_index = pos;
ffm->file_size = file_size;
}
| 1threat
|
static int initFilter(int16_t **outFilter, int32_t **filterPos,
int *outFilterSize, int xInc, int srcW, int dstW,
int filterAlign, int one, int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter,
double param[2], int is_horizontal)
{
int i;
int filterSize;
int filter2Size;
int minFilterSize;
int64_t *filter = NULL;
int64_t *filter2 = NULL;
const int64_t fone = 1LL << 54;
int ret = -1;
emms_c();
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10) {
int i;
filterSize = 1;
FF_ALLOCZ_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
for (i = 0; i < dstW; i++) {
filter[i * filterSize] = fone;
(*filterPos)[i] = i;
}
} else if (flags & SWS_POINT) {
int i;
int xDstInSrc;
filterSize = 1;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
(*filterPos)[i] = xx;
filter[i] = fone;
xDstInSrc += xInc;
}
} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||
(flags & SWS_FAST_BILINEAR)) {
int i;
int xDstInSrc;
filterSize = 2;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
int j;
(*filterPos)[i] = xx;
/ linear interpolate / area averaging
for (j = 0; j < filterSize; j++) {
int64_t coeff = fone - FFABS((xx << 16) - xDstInSrc) *
(fone >> 16);
if (coeff < 0)
coeff = 0;
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += xInc;
}
} else {
int64_t xDstInSrc;
int sizeFactor;
if (flags & SWS_BICUBIC)
sizeFactor = 4;
else if (flags & SWS_X)
sizeFactor = 8;
else if (flags & SWS_AREA)
sizeFactor = 1;
else if (flags & SWS_GAUSS)
sizeFactor = 8;
else if (flags & SWS_LANCZOS)
sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;
else if (flags & SWS_SINC)
sizeFactor = 20;
else if (flags & SWS_SPLINE)
sizeFactor = 20;
else if (flags & SWS_BILINEAR)
sizeFactor = 2;
else {
sizeFactor = 0;
assert(0);
}
if (xInc <= 1 << 16)
filterSize = 1 + sizeFactor;
else
filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
filterSize = FFMIN(filterSize, srcW - 2);
filterSize = FFMAX(filterSize, 1);
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc - 0x10000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
int j;
(*filterPos)[i] = xx;
for (j = 0; j < filterSize; j++) {
int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
double floatd;
int64_t coeff;
if (xInc > 1 << 16)
d = d * dstW / srcW;
floatd = d * (1.0 / (1 << 30));
if (flags & SWS_BICUBIC) {
int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);
int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);
if (d >= 1LL << 31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL << 30)
coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
(-18 * (1 << 24) + 12 * B + 6 * C) * dd +
(6 * (1 << 24) - 2 * B) * (1 << 30);
else
coeff = (-B - 6 * C) * ddd +
(6 * B + 30 * C) * dd +
(-12 * B - 48 * C) * d +
(8 * B + 24 * C) * (1 << 30);
}
coeff *= fone >> (30 + 24);
}
#if 0
else if (flags & SWS_X) {
double p = param ? param * 0.01 : 0.3;
coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
coeff *= pow(2.0, -p * d * d);
}
#endif
else if (flags & SWS_X) {
double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double c;
if (floatd < 1.0)
c = cos(floatd * M_PI);
else
c = -1.0;
if (c < 0.0)
c = -pow(-c, A);
else
c = pow(c, A);
coeff = (c * 0.5 + 0.5) * fone;
} else if (flags & SWS_AREA) {
int64_t d2 = d - (1 << 29);
if (d2 * xInc < -(1LL << (29 + 16)))
coeff = 1.0 * (1LL << (30 + 16));
else if (d2 * xInc < (1LL << (29 + 16)))
coeff = -d2 * xInc + (1LL << (29 + 16));
else
coeff = 0.0;
coeff *= fone >> (30 + 16);
} else if (flags & SWS_GAUSS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, -p * floatd * floatd)) * fone;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
} else if (flags & SWS_LANCZOS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
(floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
if (floatd > p)
coeff = 0;
} else if (flags & SWS_BILINEAR) {
coeff = (1 << 30) - d;
if (coeff < 0)
coeff = 0;
coeff *= fone >> 30;
} else if (flags & SWS_SPLINE) {
double p = -2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone;
} else {
coeff = 0.0;
assert(0);
}
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += 2 * xInc;
}
}
assert(filterSize > 0);
filter2Size = filterSize;
if (srcFilter)
filter2Size += srcFilter->length - 1;
if (dstFilter)
filter2Size += dstFilter->length - 1;
assert(filter2Size > 0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail);
for (i = 0; i < dstW; i++) {
int j, k;
if (srcFilter) {
for (k = 0; k < srcFilter->length; k++) {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + k + j] +=
srcFilter->coeff[k] * filter[i * filterSize + j];
}
} else {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + j] = filter[i * filterSize + j];
}
(*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
}
av_freep(&filter);
minFilterSize = 0;
for (i = dstW - 1; i >= 0; i--) {
int min = filter2Size;
int j;
int64_t cutOff = 0.0;
for (j = 0; j < filter2Size; j++) {
int k;
cutOff += FFABS(filter2[i * filter2Size]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
break;
for (k = 1; k < filter2Size; k++)
filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
filter2[i * filter2Size + k - 1] = 0;
(*filterPos)[i]++;
}
cutOff = 0;
for (j = filter2Size - 1; j > 0; j--) {
cutOff += FFABS(filter2[i * filter2Size + j]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
min--;
}
if (min > minFilterSize)
minFilterSize = min;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
if (minFilterSize < 5)
filterAlign = 4;
if (minFilterSize < 3)
filterAlign = 1;
}
if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
if (minFilterSize == 1 && filterAlign == 2)
filterAlign = 1;
}
assert(minFilterSize > 0);
filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
assert(filterSize > 0);
filter = av_malloc(filterSize * dstW * sizeof(*filter));
if (filterSize >= MAX_FILTER_SIZE * 16 /
((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize = filterSize;
if (flags & SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE,
"SwScaler: reducing / aligning filtersize %d -> %d\n",
filter2Size, filterSize);
for (i = 0; i < dstW; i++) {
int j;
for (j = 0; j < filterSize; j++) {
if (j >= filter2Size)
filter[i * filterSize + j] = 0;
else
filter[i * filterSize + j] = filter2[i * filter2Size + j];
if ((flags & SWS_BITEXACT) && j >= minFilterSize)
filter[i * filterSize + j] = 0;
}
}
if (is_horizontal) {
for (i = 0; i < dstW; i++) {
int j;
if ((*filterPos)[i] < 0) {
to compensate for filterPos
for (j = 1; j < filterSize; j++) {
int left = FFMAX(j + (*filterPos)[i], 0);
filter[i * filterSize + left] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = 0;
}
if ((*filterPos)[i] + filterSize > srcW) {
int shift = (*filterPos)[i] + filterSize - srcW;
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = srcW - filterSize;
}
}
}
FF_ALLOCZ_OR_GOTO(NULL, *outFilter,
*outFilterSize * (dstW + 3) * sizeof(int16_t), fail);
for (i = 0; i < dstW; i++) {
int j;
int64_t error = 0;
int64_t sum = 0;
for (j = 0; j < filterSize; j++) {
sum += filter[i * filterSize + j];
}
sum = (sum + one / 2) / one;
for (j = 0; j < *outFilterSize; j++) {
int64_t v = filter[i * filterSize + j] + error;
int intV = ROUNDED_DIV(v, sum);
(*outFilter)[i * (*outFilterSize) + j] = intV;
error = v - intV * sum;
}
}
(*filterPos)[dstW + 0] =
(*filterPos)[dstW + 1] =
(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
for (i = 0; i < *outFilterSize; i++) {
int k = (dstW - 1) * (*outFilterSize) + i;
(*outFilter)[k + 1 * (*outFilterSize)] =
(*outFilter)[k + 2 * (*outFilterSize)] =
(*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
}
ret = 0;
fail:
av_free(filter);
av_free(filter2);
return ret;
}
| 1threat
|
The generic parameters Any of kotlin are converted to wildcards(?) : <p>I encountered an issue when I used kotlin and retrofit2,The generic parameters of kotlin are converted to wildcards(?),but not in java.</p>
<p>now, I need a parameter <code>Map<String, Object></code>(The key is the String type, the value is not fixed) in java,convert to kotlin code is <code>Map<String, Any></code>.</p>
<p>But retrofit treats them differently.</p>
<p><code>Map<String, Object></code> in java be compiled into <code>[java.util.Map<java.lang.String, java.lang.Object>]</code>,and works correctly.</p>
<p><code>Map<String, Any></code> in kotlin be compiled into <code>[java.util.Map<java.lang.String, ?>]</code>,and the retrofit2 throws parameterError(Parameter type must not include a type variable or wildcard).</p>
<p>1、Retrofit related code</p>
<pre><code>public ServiceMethod build() {
……
for (int p = 0; p < parameterCount; p++) {
Type parameterType = parameterTypes[p];
if (Utils.hasUnresolvableType(parameterType)) {
throw parameterError(p, "Parameter type must not include a type variable or wildcard: %s", parameterType);
}
……
}
……
}
</code></pre>
<p>Utils.hasUnresolvableType(parameterType) method is quoted as follows</p>
<pre><code>final class Utils {
……
static boolean hasUnresolvableType(Type type) {
……
if (type instanceof WildcardType) {
return true;
}
……
}
……
}
</code></pre>
<p>2、interface in java, I need a parameter <code>Map<String, Object></code>(The key is the String type, the value is not fixed), it be compiled into <code>[java.util.Map<java.lang.String, java.lang.Object>]</code>,and works correctly.</p>
<pre><code>@GET("/index.html")
Observable<ResponseBody> getQueryMap(@QueryMap Map<String, Object> params);
</code></pre>
<p>3、interface in kotlin,I need a parameter <code>Map<String, Any></code>(The key is the String type, the value is not fixed), but it be compiled into <code>[java.util.Map<java.lang.String, ?>]</code>,and the retrofit2 throws parameterError(Parameter type must not include a type variable or wildcard).</p>
<pre><code>@GET("/index.html")
fun getQueryMap(@QueryMap paramsMap: Map<String, Any>): Observable<ResponseBody>
</code></pre>
| 0debug
|
Return a result from a database using Entity Framework : <p>I am trying to use this method to return a boolean value based on whether or not the custody already exists in the database.</p>
<pre><code>var custody = db.Custodies.LastOrDefault(c => c.studentId == id);
if (db.Custodies.Contains(custody) && custody.custodyEndTime == null)
{
return true;
}
return false;
}
</code></pre>
<p>The Custodies table uses a composite primary key but I only want to search by studentId, so I can't use Find(). I want to find the custody entry based on the studentId to check if that student is currently in a custody with no custodyEndTime.</p>
<p>I tried using a linq query but that gave me an anonymous type and it complained about that too.</p>
<p>Any help would be great.</p>
<p>Cheers.</p>
| 0debug
|
Can any one provide the code for merging two images in django : <p>I tried merging two images in django. But I am unsuccessful can any one please provide me code for merging two imges such that , one image should be placed on another and to be saved as .jpg. My mail id is srikanthmadireddy78@gamil.com</p>
| 0debug
|
How to sum & count in attendance using pivot in sqlserver : I have one Table Mark_Attendance and it contains the
Class | [Status] | [DateTime] | S_Adm_No | Gender
NUR | P | 2017-04-19 | 1101 | Male
NUR | A | 2017-04-19 | 1102 | Male
NUR | P | 2017-04-19 | 1103 | Female
NUR | A | 2017-04-19 | 1104 | Female
KG | P | 2017-04-19 | 1105 | Male
KG | A | 2017-04-19 | 1106 | Male
KG | P | 2017-04-19 | 1107 | Female
KG | A | 2017-04-19 | 1108 | Female
Now I want to show my result like
Class|ttl|total_male|ttl_FeMale|Ttl_Pr|Pr_Male|Pr_Female|Ttl_Ab|Ab_Female|Ab_Mal2
NUR |4 | 2 | 2 | 2 |2 | 2 |2 |2 |2
KG |4 | 2 | 2 | 2 |2 | 2 |2 |2 |2
For getting this result what query should I use in sqlserver
Please help any one. Its very urgent....
| 0debug
|
static int usb_uhci_common_initfn(UHCIState *s)
{
uint8_t *pci_conf = s->dev.config;
int i;
pci_conf[PCI_REVISION_ID] = 0x01;
pci_conf[PCI_CLASS_PROG] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
pci_conf[PCI_INTERRUPT_PIN] = 4;
pci_conf[0x60] = 0x10;
usb_bus_new(&s->bus, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
usb_port_location(&s->ports[i].port, NULL, i+1);
}
s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
s->expire_time = qemu_get_clock_ns(vm_clock) +
(get_ticks_per_sec() / FRAME_TIMER_FREQ);
s->num_ports_vmstate = NB_PORTS;
qemu_register_reset(uhci_reset, s);
pci_register_bar(&s->dev, 4, 0x20,
PCI_BASE_ADDRESS_SPACE_IO, uhci_map);
return 0;
}
| 1threat
|
void input_type_enum(Visitor *v, int *obj, const char *strings[],
const char *kind, const char *name,
Error **errp)
{
int64_t value = 0;
char *enum_str;
assert(strings);
visit_type_str(v, &enum_str, name, errp);
if (error_is_set(errp)) {
return;
}
while (strings[value] != NULL) {
if (strcmp(strings[value], enum_str) == 0) {
break;
}
value++;
}
if (strings[value] == NULL) {
error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
g_free(enum_str);
return;
}
g_free(enum_str);
*obj = value;
}
| 1threat
|
static void s390_virtio_net_realize(VirtIOS390Device *s390_dev, Error **errp)
{
DeviceState *qdev = DEVICE(s390_dev);
VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
virtio_net_set_config_size(&dev->vdev, s390_dev->host_features);
virtio_net_set_netclient_name(&dev->vdev, qdev->id,
object_get_typename(OBJECT(qdev)));
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
}
| 1threat
|
static uint64_t pic_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
HeathrowPICS *s = opaque;
HeathrowPIC *pic;
unsigned int n;
uint32_t value;
n = ((addr & 0xfff) - 0x10) >> 4;
if (n >= 2) {
value = 0;
} else {
pic = &s->pics[n];
switch(addr & 0xf) {
case 0x0:
value = pic->events;
break;
case 0x4:
value = pic->mask;
break;
case 0xc:
value = pic->levels;
break;
default:
value = 0;
break;
}
}
PIC_DPRINTF("readl: " TARGET_FMT_plx " %u: %08x\n", addr, n, value);
return value;
}
| 1threat
|
Decentralized Chat Communication Protocl : I am designing a chat application in which there is no central server or db handling all the incoming and outgoing messages. It will be entirely decentralized.
A sum up of my project and its requirements
- Each user will communicate via android phone to a particular `node` allotted to them. This node will then communicate directly with the `node` belonging to the user he wishes to message
- Chat messages will be communicated between `nodes` via a `p2p` protocol forked from one of the libraries used for `Ethereum`
- The chat will have a limited number of users, 1500-2500
- Mapping the nodes to the users will be done via DHT and is not an issue
- I want to depend as little as possible on GCM
- The server will be written entirely in Node js. I have read extensively on XMPP, socketio and websockets but am unable to come to a conclusion on what to use. Keeping in mind that the code I write will be deployed across multiple `nodes` i.e. servers
- And of course, the app will have a backround server running and will need to show notifications for new messages when the app is in the back ground or not running at all
- A quick deployment is the least important factor for me. I am just looking for the most powerful and customizable end product
- I would like to stick with nodejs for the server
Is the primary advantage of XMPP over websockets that in XMPP a lot of the features needed for chat is out-of-the-box? Or is there more to it?
I have a list of libraries obtained from various stack questions and seen examples for xmpp and websocket implementations.
An increase in delay of a 1-2 seconds is NOT a problem in my case, but battery conversation is important.
[This link][1] suggests battery consumption with websockets is not a problem.
[1]: http://stackoverflow.com/questions/19033390/nodejs-socketio-android-battery-issue
| 0debug
|
Angular 2 Errors and Typescript - how to debug? : <p>I've just started a project to learn Angular2 and Typescript+Javascript. I come from a Java background and my approach to debugging projects is usually a combination of stack traces, compile errors, and - on larger projects - lots of test cases. However, much of this doesn't seem to directly translate to the world of web-dev; particularly debugging my code that's interacting with Angular2's libraries.</p>
<p>Could anyone suggest any approaches that I can take to debug code working with Angular2? Specifically; how can I see what parts of my HTML/TS is causing issues? I've checked the console, from which I can see that I've broken Angular2, but it doesn't seem much more informative from that.</p>
<p>Just to clarify; I don't want help for this specific instance. I'd like to learn how to diagnose+fix these problems myself.</p>
| 0debug
|
static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries, sample_size, field_size, num_bytes;
GetBitContext gb;
unsigned char* buf;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
get_byte(pb);
get_be24(pb);
if (atom.type == MKTAG('s','t','s','z')) {
sample_size = get_be32(pb);
if (!sc->sample_size)
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
get_be24(pb);
field_size = get_byte(pb);
}
entries = get_be32(pb);
dprintf(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
sc->sample_count = entries;
if (sample_size)
return 0;
if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
return -1;
}
if(entries >= UINT_MAX / sizeof(int))
return -1;
sc->sample_sizes = av_malloc(entries * sizeof(int));
if (!sc->sample_sizes)
return AVERROR(ENOMEM);
num_bytes = (entries*field_size+4)>>3;
buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf) {
av_freep(&sc->sample_sizes);
return AVERROR(ENOMEM);
}
if (get_buffer(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
}
init_get_bits(&gb, buf, 8*num_bytes);
for(i=0; i<entries; i++)
sc->sample_sizes[i] = get_bits_long(&gb, field_size);
av_free(buf);
return 0;
}
| 1threat
|
static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
uint8_t *buf_end, *buf_ptr;
int ret, start_code, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
dprintf("fill_buffer\n");
*data_size = 0;
if (buf_size == 0) {
if (s2->picture_number > 0) {
*picture= *(AVFrame*)&s2->next_picture;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(s2->flags&CODEC_FLAG_TRUNCATED){
int next;
next= mpeg1_find_frame_end(s2, buf, buf_size);
if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 )
return buf_size;
}
buf_ptr = buf;
buf_end = buf + buf_size;
#if 0
if (s->repeat_field % 2 == 1) {
s->repeat_field++;
if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {
*data_size = sizeof(AVPicture);
goto the_end;
}
}
#endif
for(;;) {
start_code = find_start_code(&buf_ptr, buf_end);
if (start_code < 0){
printf("missing end of picture\n");
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}
input_size = buf_end - buf_ptr;
switch(start_code) {
case SEQ_START_CODE:
mpeg1_decode_sequence(avctx, buf_ptr,
input_size);
break;
case PICTURE_START_CODE:
mpeg1_decode_picture(avctx,
buf_ptr, input_size);
break;
case EXT_START_CODE:
mpeg_decode_extension(avctx,
buf_ptr, input_size);
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx,
buf_ptr, input_size);
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;
if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
if(avctx->hurry_up>=5) break;
if (!s->mpeg_enc_ctx_allocated) break;
ret = mpeg_decode_slice(avctx, picture,
start_code, &buf_ptr, input_size);
if (ret == DECODE_SLICE_EOP) {
if(s2->last_picture_ptr)
*data_size = sizeof(AVPicture);
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}else if(ret < 0){
if(ret == DECODE_SLICE_ERROR)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
fprintf(stderr,"Error while decoding slice\n");
if(ret==DECODE_SLICE_FATAL_ERROR) return -1;
}
}
break;
}
}
}
| 1threat
|
File Upload Methods With PHP : <p>I'm going to try image file upload.
Then, I thought there were two choices.
First, I can save the image file into the directory which is not available for viewers.
Second idea is that I can save the image binary data into the database.</p>
<p>Which is better? Or, could you tell me the advantages and disadvantages of these methods?</p>
<p>Finally, I'm going to use CakePHP.</p>
| 0debug
|
void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
DisasContext dc1, *dc = &dc1;
target_ulong pc_start;
target_ulong next_page_start;
int num_insns;
int max_insns;
if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) {
gen_intermediate_code_a64(cpu, tb);
return;
}
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->condjmp = 0;
dc->aarch64 = 0;
dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) &&
!arm_el_is_aa64(env, 3);
dc->thumb = ARM_TBFLAG_THUMB(tb->flags);
dc->bswap_code = ARM_TBFLAG_BSWAP_CODE(tb->flags);
dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1;
dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4;
dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags);
dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);
#if !defined(CONFIG_USER_ONLY)
dc->user = (dc->current_el == 0);
#endif
dc->ns = ARM_TBFLAG_NS(tb->flags);
dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(tb->flags);
dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags);
dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags);
dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags);
dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags);
dc->cp_regs = cpu->cp_regs;
dc->features = env->features;
dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
dc->is_ldex = false;
dc->ss_same_el = false;
cpu_F0s = tcg_temp_new_i32();
cpu_F1s = tcg_temp_new_i32();
cpu_F0d = tcg_temp_new_i64();
cpu_F1d = tcg_temp_new_i64();
cpu_V0 = cpu_F0d;
cpu_V1 = cpu_F1d;
cpu_M0 = tcg_temp_new_i64();
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
gen_tb_start(tb);
tcg_clear_temp_count();
if (dc->condexec_mask || dc->condexec_cond)
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
store_cpu_field(tmp, condexec_bits);
}
do {
tcg_gen_insn_start(dc->pc,
(dc->condexec_cond << 4) | (dc->condexec_mask >> 1));
num_insns++;
#ifdef CONFIG_USER_ONLY
if (dc->pc >= 0xffff0000) {
gen_exception_internal(EXCP_KERNEL_TRAP);
dc->is_jmp = DISAS_UPDATE;
break;
}
#else
if (dc->pc >= 0xfffffff0 && arm_dc_feature(dc, ARM_FEATURE_M)) {
gen_exception_internal(EXCP_EXCEPTION_EXIT);
dc->is_jmp = DISAS_UPDATE;
break;
}
#endif
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
CPUBreakpoint *bp;
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
dc->pc += 2;
goto done_generating;
}
}
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (dc->ss_active && !dc->pstate_ss) {
assert(num_insns == 1);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
goto done_generating;
}
if (dc->thumb) {
disas_thumb_insn(env, dc);
if (dc->condexec_mask) {
dc->condexec_cond = (dc->condexec_cond & 0xe)
| ((dc->condexec_mask >> 4) & 1);
dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f;
if (dc->condexec_mask == 0) {
dc->condexec_cond = 0;
}
}
} else {
unsigned int insn = arm_ldl_code(env, dc->pc, dc->bswap_code);
dc->pc += 4;
disas_arm_insn(dc, insn);
}
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
dc->pc);
}
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
if (dc->condjmp) {
cpu_abort(cs, "IO on conditional branch instruction");
}
gen_io_end();
}
if (unlikely(cs->singlestep_enabled || dc->ss_active)) {
if (dc->condjmp) {
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI) {
gen_ss_advance(dc);
gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
default_exception_el(dc));
} else if (dc->is_jmp == DISAS_HVC) {
gen_ss_advance(dc);
gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
} else if (dc->is_jmp == DISAS_SMC) {
gen_ss_advance(dc);
gen_exception(EXCP_SMC, syn_aa32_smc(), 3);
} else if (dc->ss_active) {
gen_step_complete_exception(dc);
} else {
gen_exception_internal(EXCP_DEBUG);
}
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_set_pc_im(dc, dc->pc);
dc->condjmp = 0;
}
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI && !dc->condjmp) {
gen_ss_advance(dc);
gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
default_exception_el(dc));
} else if (dc->is_jmp == DISAS_HVC && !dc->condjmp) {
gen_ss_advance(dc);
gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
} else if (dc->is_jmp == DISAS_SMC && !dc->condjmp) {
gen_ss_advance(dc);
gen_exception(EXCP_SMC, syn_aa32_smc(), 3);
} else if (dc->ss_active) {
gen_step_complete_exception(dc);
} else {
gen_exception_internal(EXCP_DEBUG);
}
} else {
gen_set_condexec(dc);
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
case DISAS_WFI:
gen_helper_wfi(cpu_env);
tcg_gen_exit_tb(0);
break;
case DISAS_WFE:
gen_helper_wfe(cpu_env);
break;
case DISAS_YIELD:
gen_helper_yield(cpu_env);
break;
case DISAS_SWI:
gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
default_exception_el(dc));
break;
case DISAS_HVC:
gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
break;
case DISAS_SMC:
gen_exception(EXCP_SMC, syn_aa32_smc(), 3);
break;
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_set_condexec(dc);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
done_generating:
gen_tb_end(tb, num_insns);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, dc->pc - pc_start,
dc->thumb | (dc->bswap_code << 1));
qemu_log("\n");
}
#endif
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
| 1threat
|
Amazon API Implementation in Android Studio product base : recently tried Google Books API and got beautiful result.
I want to create a small android window which can show me products from amazon.
it will be great help if you can help me even a littile bit of it.
| 0debug
|
vba excel code followhyperlink : I have excel, containing **cell A1 as c:\user\download** and **cell A2 contains c:\user** and **cell A3 contains c:\**.
Where i used the coding as follows :
Sub opendfolder()
Dim myfolder As String, nextfolder as string, nextfolder1 as string
myfolder = Range("a1").Value
ActiveWorkbook.FollowHyperlink myfolder
nextfolder = range("a2").value
ActiveWorkbook.FollowHyperlink nextfolder
nextfolder1 = range("a3").value
ActiveWorkbook.FollowHyperlink nextfolder1
End Sub
but my problem is now is that vba code should execute to check first the cell a1,if it got error then goto cell a2 and so on...
**And one more** if vba code able to execute at cell a1 level only then there is no need to execute next cells a2 or a3. Now the coding which i have written is executing all the three.
Can you help me writing the code which will be execute at cell a1, if a1 fails then go to a2. if cell a2 is able to execute successfully then it should not execute to code at cell a3. the code should stop at cell a2.
If fails at a2 cell, then it should try for cell a3.
Please help me....I was not able to get the logic..
how to write a code in the above scenario.
Looking for the reply...asap.....
| 0debug
|
static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width)
{
#ifdef HAVE_MMX
asm volatile(
"movq "MANGLE(bm01010101)", %%mm2\n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"pand %%mm2, %%mm0 \n\t"
"pand %%mm2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((long)-width), "r" (src+width*2), "r" (dst+width)
: "%"REG_a
);
#else
int i;
for(i=0; i<width; i++)
dst[i]= src[2*i];
#endif
}
| 1threat
|
Unable to import tensorflow, importerror libcublas : Hello I am new to tensorflow.
I installed tensorflow-gpu. I am using the virtualenv installation for Tensorflow.
Ubuntu version 16.04
Cuda compilation tools, release 7.5, V7.5.17
Nvidia Driver:390 (latest)
I have already linked cuda to my .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.1/extras/CUPTI/lib64
When I try:
import tensorflow as tf
I receive the following error:
>>> import tensorflow
Traceback (most recent call last):
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/rosi/udacity/TensorFlow/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/rosi/udacity/TensorFlow/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/rosi/udacity/TensorFlow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/rosi/udacity/TensorFlow/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/rosi/udacity/TensorFlow/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Kindly suggest how to fix this issue.
| 0debug
|
get merged data from List of object based on properties in C# : <p>I am using a List , where AccountInformation has three properties </p>
<pre><code>public class AccountInformation
{
public string AccountNumber{ get; set; }
public int StartDate { get; set; }
public int EndDate{ get; set; }
}
</code></pre>
<p>Now I am getting my List of data something like this</p>
<pre><code>AccountNumber StartDate EndDate
AC1 20150101 20150110
AC1 20150110 20150111
AC1 20150111 20150112
AC2 20150112 20150115
AC1 20150116 20150120
AC1 20150121 20150125
AC2 20150125 20150130
AC2 20150130 20150205
</code></pre>
<p>Now I need to get this data as final output in below fashion</p>
<pre><code> AccountNumber StartDate EndDate
AC1 20150101 20150111
AC2 20150112 20150115
AC1 20150116 20150120
AC1 20150121 20150125
AC2 20150125 20150005
</code></pre>
<p>Means wherever I am getting consecutive AccountNumber as same and EndDate of first row is same as StartDate of next row, I need to merge those rows.</p>
<p>Any help is appreciated.</p>
| 0debug
|
.xml:13: error: Error parsing XML: mismatched tag : Error? ._. que error estoy cometiendo?, antes de añadir la linea 11 o por ahí funcionaba perfectamente, pero no veo en que me equivoque... Me dice error: Error parsing XML: mismatched tag, este error me da en los logs
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/GB_Mods"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cmwmobile="http://schemas.android.com/apk/res/com.whatsapp">
<PreferenceCategory android:title="HPWhatsApp 4.0" android:key="cat_wa">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_preguntas" android:title="HPWhatsApp WEB" android:key="settings_faq" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_actualizaciones" android:title="@string/updatess" android:key="updates_key" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_Thanks" android:title="Donar" android:summary="Donar al desarrollador" >
<intent android:action="android.intent.action.VIEW" android:data="https://paypal.me/Hectorc4rp" />
<PreferenceScreen android:icon="@drawable/ic_9" android:title="Contactar al desarrollador" android:summary="Habla con Héctor Paez, creador de HPWhatsApp" >
<intent android:action="android.intent.action.VIEW" android:data="https://api.whatsapp.com/send?phone=543814805749" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/themes">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_descargar" android:title="@string/download_themes" android:key="download_themes" android:summary="@string/download_themes_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_temas" android:title="@string/more_preferences" android:key="themes_key" android:summary="@string/more_preferences_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_web" android:title="Más temas" android:summary="Descarga temas hechos por otras personas" >
<intent android:action="android.intent.action.VIEW" android:data="http://www.whatsappthemes.net/search/label/GBWhatsApp%20Themes" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/appearance">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_1" android:title="@string/conversation_colors" android:key="chat_colors" android:summary="@string/conversation_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_2" android:title="@string/chats_colors" android:key="chats_colors" android:summary="@string/chats_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_3" android:title="@string/popup_colors" android:key="popup_key" android:summary="@string/popup_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_4" android:title="@string/widgets" android:key="widget_key" android:summary="@string/widgets_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_5" android:title="@string/media_sharing_pref" android:key="media_sharing_key" android:summary="@string/media_sharing_pref_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_6" android:title="@string/others" android:key="others_key" android:summary="@string/others_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_7" android:title="@string/gb_lock" android:key="gb_lock" />
<Preference android:icon="@drawable/ic_actualizaciones" android:title="@string/clean_whatsapp_pref" android:key="clean_whatsapp_screen" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_8" android:title="@string/read_log_pref" android:key="logs_key" />
<ListPreference android:icon="@drawable/ic_lang" android:entries="@array/language_array" android:title="@string/language_title" android:key="gb_language_key" android:defaultValue="0" android:entryValues="@array/language_values" />
<Preference android:icon="@drawable/ic_temas" android:title="@string/change_font_pref" android:key="gb_fonts" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/GB_About" android:key="cat_about">
<Preference android:icon="@drawable/ic_twitter" android:title="@string/pref_facebook" android:key="facebook" android:summary="@string/pref_sum_facebook" />
<Preference android:icon="@drawable/ic_twi" android:title="@string/google_plus" android:key="google_plus" android:summary="@string/google_plus_sum" />
<Preference android:icon="@drawable/ic_web" android:title="@string/pref_sum_blogger" android:key="about" android:summary="HPWhatsApp" />
<Preference android:icon="@drawable/ic_twitter" android:title="Página de Facebook" android:summary="Regalanos un me gusta en Facebook" >
<intent android:action="android.intent.action.VIEW" android:data="https://facebook.com/todo.para.android.hp" />
<Preference android:icon="@drawable/ic_compartir" android:title="@string/GBShare" android:key="share" android:summary="@string/GBShareSum" />
<Preference android:icon="@drawable/ic_reportar" android:title="@string/GB_Report" android:key="report" />
<Preference android:icon="@drawable/ic_Thanks" android:title="@string/Thanks" android:key="Thanks" />
</PreferenceCategory>
</PreferenceScreen>
| 0debug
|
Is there a way to execute a scala class using eclipse? : <p>Im very new to Scala programming and learning it. One of the interesting thing for me in Scala is most of the times the topics are explain by writing Scala Objects.
I tried to write a small scala class in eclipse in two separate classes and created an object like below.</p>
<pre><code>package com.scala.programs
class DisplayStatement {
def hello(name:String):String = {
return "Hello " + name
}
}
</code></pre>
<p>My Main class is in another packacge and in another class:</p>
<pre><code>package com.scala.mainclasses
import com.scala.programs.DisplayStatement
class Display {
def main(args: Array[String]) {
DisplayStatement ds = new DisplayStatement();
ds.hello("scala");
}
}
</code></pre>
<p>I tried to do it just like it is Java. But Im getting error in these two statements.</p>
<pre><code>DisplayStatement ds = new DisplayStatement();
ds.hello("scala");
</code></pre>
<p>Below are the error messages:</p>
<pre><code>Error Messages: not found: value DisplayStatement
not found: value ds
</code></pre>
<p>I understood it when a scala object is written and executed.
I know that Im making some mistake here but can anyone tell me how to create an object of a class and execute it in Scala programming or is it possible and why is it most of the times the programs are written in the form of Object directly rather class.</p>
| 0debug
|
RPS Game While and if loops not able to get working : I don't know why but i keep getting the code ending straight after the input part
I have tried using elif but i get invalid syntax
import getpass
answer1 = getpass.getpass(prompt = "Hello Player 1, Please pick either ROCK (1) SCISSORS (2) OR PAPER (3) \n")
answer2 = input(("Hello Player 2, Please pick either ROCK (1) SCISSORS (2) OR PAPER (3) \n"))
Forever = 0
while Forever < 1:
if answer1 == 1 and answer2 == 1:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 2:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 3:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 1 and answer2 == 2:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 1:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 3:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 1:
print('Player 2 wins !')
Forever = Forever + 1
if answer1 == 1 and answer2 == 3:
print('Player 2 wins !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 2:
print('Player 2 wins !')
Forever = Forever + 1
The code never ends as well.
| 0debug
|
static int hls_window(AVFormatContext *s, int last)
{
HLSContext *hls = s->priv_data;
HLSSegment *en;
int target_duration = 0;
int ret = 0;
AVIOContext *out = NULL;
AVIOContext *sub_out = NULL;
char temp_filename[1024];
int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->nb_entries);
int version = 3;
const char *proto = avio_find_protocol_name(s->filename);
int use_rename = proto && !strcmp(proto, "file");
static unsigned warned_non_file;
char *key_uri = NULL;
char *iv_string = NULL;
AVDictionary *options = NULL;
double prog_date_time = hls->initial_prog_date_time;
int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
if (byterange_mode) {
version = 4;
sequence = 0;
}
if (hls->segment_type == SEGMENT_TYPE_FMP4) {
version = 7;
}
if (!use_rename && !warned_non_file++)
av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this may lead to races and temporary partial files\n");
set_http_options(s, &options, hls);
snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : "%s", s->filename);
if ((ret = s->io_open(s, &out, temp_filename, AVIO_FLAG_WRITE, &options)) < 0)
goto fail;
for (en = hls->segments; en; en = en->next) {
if (target_duration <= en->duration)
target_duration = get_int_from_double(en->duration);
}
hls->discontinuity_set = 0;
write_m3u8_head_block(hls, out, version, target_duration, sequence);
if (hls->pl_type == PLAYLIST_TYPE_EVENT) {
avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
} else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
}
if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && hls->discontinuity_set==0 ){
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
hls->discontinuity_set = 1;
}
for (en = hls->segments; en; en = en->next) {
if ((hls->encrypt || hls->key_info_file) && (!key_uri || strcmp(en->key_uri, key_uri) ||
av_strcasecmp(en->iv_string, iv_string))) {
avio_printf(out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
if (*en->iv_string)
avio_printf(out, ",IV=0x%s", en->iv_string);
avio_printf(out, "\n");
key_uri = en->key_uri;
iv_string = en->iv_string;
}
if (en->discont) {
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
}
if ((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == hls->segments)) {
avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", hls->fmp4_init_filename);
if (hls->flags & HLS_SINGLE_FILE) {
avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", en->size, en->pos);
}
avio_printf(out, "\n");
} else {
if (hls->flags & HLS_ROUND_DURATIONS)
avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration));
else
avio_printf(out, "#EXTINF:%f,\n", en->duration);
if (byterange_mode)
avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n",
en->size, en->pos);
}
if (hls->flags & HLS_PROGRAM_DATE_TIME) {
time_t tt, wrongsecs;
int milli;
struct tm *tm, tmpbuf;
char buf0[128], buf1[128];
tt = (int64_t)prog_date_time;
milli = av_clip(lrint(1000*(prog_date_time - tt)), 0, 999);
tm = localtime_r(&tt, &tmpbuf);
strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm);
if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') {
int tz_min, dst = tm->tm_isdst;
tm = gmtime_r(&tt, &tmpbuf);
tm->tm_isdst = dst;
wrongsecs = mktime(tm);
tz_min = (abs(wrongsecs - tt) + 30) / 60;
snprintf(buf1, sizeof(buf1),
"%c%02d%02d",
wrongsecs <= tt ? '+' : '-',
tz_min / 60,
tz_min % 60);
}
avio_printf(out, "#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
prog_date_time += en->duration;
}
if (!((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == hls->segments))) {
if (hls->baseurl)
avio_printf(out, "%s", hls->baseurl);
avio_printf(out, "%s\n", en->filename);
}
}
if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
avio_printf(out, "#EXT-X-ENDLIST\n");
if( hls->vtt_m3u8_name ) {
if ((ret = s->io_open(s, &sub_out, hls->vtt_m3u8_name, AVIO_FLAG_WRITE, &options)) < 0)
goto fail;
write_m3u8_head_block(hls, sub_out, version, target_duration, sequence);
for (en = hls->segments; en; en = en->next) {
avio_printf(sub_out, "#EXTINF:%f,\n", en->duration);
if (byterange_mode)
avio_printf(sub_out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n",
en->size, en->pos);
if (hls->baseurl)
avio_printf(sub_out, "%s", hls->baseurl);
avio_printf(sub_out, "%s\n", en->sub_filename);
}
if (last)
avio_printf(sub_out, "#EXT-X-ENDLIST\n");
}
fail:
av_dict_free(&options);
ff_format_io_close(s, &out);
ff_format_io_close(s, &sub_out);
if (ret >= 0 && use_rename)
ff_rename(temp_filename, s->filename, s);
return ret;
}
| 1threat
|
Real life examples of where java interfaces are necessary? : <p>I have been searching for an answer for a while so I am sorry if this has already been answered. </p>
<p>I am confused as to why inheriting empty method stubs from an interface is considered so useful in java? Is this something that is mainly used in bigger projects that i need to try to understand? Because although I know all the syntax and characteristics of interfaces, I cannot find uses for them when I am programming. I have tried to read as much as I can but this is a concept that I cannot get to 'click' in my head and I feel it is holding me back.</p>
<p>Or perhaps it is just case of good software design and I need to use them in certain scenarios whether I feel I need to or not?</p>
<p>If someone could point me in the direction of some code or preferably a project for me to do where interfaces are imperative that would be much appreciated.</p>
| 0debug
|
Bootstrap collapse has a jumpy transition : <p>I have a problem with the transition of the bootstrap navbar.
the collapse has a jumpy transition when the collapsing element has padding </p>
<p>I googled this issue and it seems that the problem is the padding:</p>
<pre><code>.menu-menu-container{
padding: 100px 30px 60px 30px;
background-color: yellow;
}
</code></pre>
<p>in fact if i remove the padding from menu-menu-container element, the animation works well, and it is very smooth </p>
<p>this i my codepen > <a href="http://codepen.io/mp1985/pen/EyOJYE" rel="noreferrer">http://codepen.io/mp1985/pen/EyOJYE</a></p>
<p>How can I achieve the same result without this weird issue?</p>
<p>any help, suggestion or advice?</p>
| 0debug
|
Can't finish the loop when asking for valid asnwers : I have a problem with my code that I can't find the solution to. I ask for questions that has to be valid but the loops just continues, and let me input.
print('Do you want to go to the store or woods?')
lists = ('woods', 'store')
while True:
answers = input()
if answers == 'store':
break
print('Going to the store...')
elif answers == 'woods':
break
print('Going to the woods...')
while lists not in answers:
print('That is not a valid answer')
| 0debug
|
static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
const uint16_t *buf1= buf0;
if (uvalpha < 2048) {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
} else {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
}
}
| 1threat
|
static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev)
{
uint8_t slot = PCI_SLOT(dev->devfn);
uint8_t func;
if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;
}
if (PCI_FUNC(dev->devfn)) {
PCIDevice *f0 = bus->devices[PCI_DEVFN(slot, 0)];
if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) {
error_report("PCI: single function device can't be populated "
"in function %x.%x", slot, PCI_FUNC(dev->devfn));
return -1;
}
return 0;
}
if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
return 0;
}
for (func = 1; func < PCI_FUNC_MAX; ++func) {
if (bus->devices[PCI_DEVFN(slot, func)]) {
error_report("PCI: %x.0 indicates single function, "
"but %x.%x is already populated.",
slot, slot, func);
return -1;
}
}
return 0;
}
| 1threat
|
How to get nanoTime from date? : <p>I want nanoTime() of last 24 hours.
long currentDate=System.nanoTime();
how to find nanoTime by subtracting 24 hours?
Is it possible to get nanoTime from Date date = new Date()?</p>
| 0debug
|
How do Dinamic binding in PHP? : I'm trying to develop a little MVC Site in PHP to work with passwords. (Without any framework like Laravel or similar, for learning purposes).
In order to do so I've write at least 4 classes and an index file:
Controller -> A base class to be extended contaning all the basic logic for controllers;
Index -> A controller class to handle with normal user's login;
Admin -> A controller class to handle with admin users's login;
Bootstrap -> A class to interpret the url passedand use as a router;
The classes are shown as follow:
libs/Controller.php
```
<?php
class Controller {
protected $view;
protected $security_level;
function __construct() {
$this->security_level = 0;
}
public function model($model) {
$path = 'models/' . ucfirst($model). '.php';
if (file_exists($path)) {
require_once ($path);
return new $model();
}
}
public function getSecurityLevel(){
return $this->securiy_level;
}
public function view($view, $data = []){
require_once('views/commom/header.php');
require_once('views/' . $view . '.php');
require_once('views/commom/footer.php');
}
}
```
controllers/Index.php
```
<?php
class Index extends Controller {
public function __construct() {
parent::__construct();
$this->model('UserModel');
//$this->securiy_level = 0;
}
public function index($error = 0) {
$this->view('index/index', ['error' => $error]);
}
public function admin($error = 0) {
$this->view('index/index_adm', ['error' => $error]);
}
public function login(){
$auth = new Authentication();
$permission = $auth->authenticate("user");
if($permission){
header("location: /account/index");
}
else{
$this->index(1);
}
}
public function login_adm(){
$auth = new Authentication();
$permission = $auth->authenticate("admin");
if($permission){
header("location: /admin/index");
}
else{
$this->admin(1);
}
}
public function signin(){
echo "method sign in invoked <br />";
}
public function logout(){
$this->view('index/logout');
}
public function lostMyPassword(){
echo "method lost invoked <br />";
}
public function details() {
$this->view->view('index/index');
}
}
```
controllers/Admin
```
<?php
//I Think that this is VERY wrong, but okay
@session_start();
class Admin extends Controller {
private $encrypt_unit;
public function __construct() {
parent::__construct();
$this->model('UserModel');
$this->encrypt_unit = new Encrypter();
$this->securiy_level = 1;
}
public function index($msg = "", $err = false){
$users = $this->recover();
$this->view('admin/index', ["msg" => $msg, "err" => $err, "users" => $users]);
}
public function create(){
$user_var = new UserModel();
$user_var->setLogin($_POST["login"]);
$user_var->setEmail($_POST["email"]);
$user_var->setPassword($this->encrypt_unit->encrypt($_POST["password"]));
$user_var->setIsAdmin($_POST["isAdmin"]);
$user_dao = new UserDAO();
$flag = $user_dao->insertUser($user_var);
if($flag)
$this->index("User created successfully", false);
else
$this->index("Can't created user, please try again", true);
}
public function recover(){
$user_dao = new UserDAO();
$all_users = $user_dao->getUsers();
$users = array();
foreach ($all_users as $value) {
array_push($users, [
"id" => $value->getId(),
"login" => $value->getLogin(),
"email" => $value->getEmail(),
"password" => $this->encrypt_unit->decrypt($value->getPassword()),
"isAdmin" => $value->getIsAdmin()
]);
}
return $users;
}
public function update(){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_var->setLogin($_POST["login"]);
$user_var->setEmail($_POST["email"]);
$user_var->setPassword($this->encrypt_unit->encrypt($_POST["password"]));
$user_dao = new UserDAO();
$flag = $user_dao->updateUser($user_var);
if($flag)
$this->index("User updated successfully", false);
else
$this->index("Can't updated user, please try again", true);
}
public function update_credential($credential_level){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_var->setIsAdmin($credential_level);
$user_dao = new UserDAO();
$flag = $user_dao->updateUserCredential($user_var);
if($flag)
$this->index("User updated successfully", false);
else
$this->index("Can't updated user, please try again", true);
}
public function delete(){
$user_var = new UserModel();
$user_var->setId($_POST["id"]);
$user_dao = new UserDAO();
$flag = $user_dao->deleteUser($user_var);
if($flag)
$this->index("User deleted successfully", false);
else
$this->index("Can't deleted user, please try again", true);
}
public function search(){
echo "method search invoked <br />";
}
}
```
libs/Bootstrap:
```
<?php
class Bootstrap {
// protected $controller;
// protected $method;
// protected $params;
function __construct() {
//$this->method = 'index';
$this->redirect();
}
public function parseUrl(){
return isset($_GET['url']) ? explode('/',filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL)) : null;
}
function redirect(){
$controller;
$method;
$params;
$url = $this->parseUrl();
if(empty($url[0])){
$controller_name = 'Index';
}
else{
$controller_name = ucfirst($url[0]);
}
$filename_controller = 'controllers/' . $controller_name . '.php';
if (file_exists($filename_controller)) {
require_once($filename_controller);
// Do this to use the rest of array to select method, and than parameters
unset($url[0]);
}
else{
$this->error("Controller $controller_name not founded");
return false;
}
$controller = new $controller_name;
//default method
$method = 'index';
if(isset($url[1])){
if (method_exists($controller, $url[1])) {
$method = $url[1];
// Do this to use the rest of array to select parameters
unset($url[1]);
}
else{
$this->error("The controller $controller_name doesn't have any public method called $url[1]");
}
}
//This 'array_values($url)' command is possible because we have unseted the first and second position of this aray before
$params = $url ? array_values($url) : [];
// Securiy comparassion?
var_dump($controller);
var_dump(get_class_methods($controller));
var_dump($controller->getSecurityLevel());
var_dump($controller->{"getSecurityLevel"}());
// if(property_exists($controller, "securiy_level")){
// $authEntity = new Authentication();
// $authEntity->auth($controller->getSecurityLevel());
// }
//(new $url[0])->{$url[1]}($url[2]);
call_user_func_array([$controller, $method], $params);
}
function error($msg="") {
//echo "error invoked: <br /> $msg <br />";
require_once('controllers/Error.php');
$errorHandler = new ErrorController();
$errorHandler->index();
return false;
}
}
```
/index.php:
```
<?php
// Use an autoloader!
require_once('libs/Bootstrap.php');
require_once('libs/Controller.php');
require_once('libs/Model.php');
require_once('libs/View.php');
// Library
require_once('libs/Database.php');
require_once('libs/ConnectionDB.php');
require_once('libs/Session.php');
require_once('libs/Authentication.php');
require_once('libs/Encrypter.php');
require_once('config/paths.php');
require_once('config/database.php');
require_once('config/passwords.php');
// DAOS
require_once('daos/UserDAO.php');
require_once('daos/AccountDAO.php');
$app = new Bootstrap();
```
My main problem is on the Bootstrap class, specifically when I try to run:
```
var_dump($controller->getSecurityLevel()); //or
var_dump($controller->{"getSecurityLevel"}());
```
This is my actual exit:
object(Index)#2 (2) { ["view":protected]=> NULL ["security_level":protected]=> int(0) }
array(12) { [0]=> string(11) "__construct" [1]=> string(5) "index" [2]=> string(5) "admin" [3]=> string(5) "login" [4]=> string(9) "login_adm" [5]=> string(6) "signin" [6]=> string(6) "logout" [7]=> string(14) "lostMyPassword" [8]=> string(7) "details" [9]=> string(5) "model" [10]=> string(16) "getSecurityLevel" [11]=> string(4) "view" }
Notice: Undefined property: Index::$securiy_level in /var/www/html/libs/Controller.php on line 21
NULL
Notice: Undefined property: Index::$securiy_level in /var/www/html/libs/Controller.php on line 21
NULL
What I cannot understand is how PHP shows me that the ```$controller``` variable has the property that I want to access, I have the method to do the access, but I cannot access. And what does means the "static" bind that PHP is trying to do when he shows: " Index::$securiy_level "
My configuration is: PHP 7, Ubuntu 16, apache2;
Any help I will thank in advanced.
If my question is not clear, please comment it too to clarify anything.
| 0debug
|
React (CRA) SW Cache "public" folder : <p>After executing the create-react-app and enabling the service workers in the <code>index.js</code>, all relevant files from the <code>src</code> folder are cached. However some of my resources reside in the <code>public</code> directory. When I run <code>npm run build</code>, the <code>asset-manifest.json</code> and <code>precache-manifest.HASH.js</code> only contain the HTML, mangled JS and CSS (all stuff from the <code>src</code> folder).</p>
<p><strong>How can I tell the service worker to additionally cache specific files from the <code>public</code> folder?</strong></p>
<p>Here is the actually generated <code>precache-manifest.e431838417905ad548a58141f8dc754b.js</code></p>
<pre><code>self.__precacheManifest = [
{
"revision": "cb0ea38f65ed9eddcc91",
"url": "/grafiti/static/js/runtime~main.cb0ea38f.js"
},
{
"revision": "2c226d1577937984bf58",
"url": "/grafiti/static/js/main.2c226d15.chunk.js"
},
{
"revision": "c88c70e5f4ff8bea6fac",
"url": "/grafiti/static/js/2.c88c70e5.chunk.js"
},
{
"revision": "2c226d1577937984bf58",
"url": "/grafiti/static/css/main.7a6fc926.chunk.css"
},
{
"revision": "980026e33c706b23b041891757cd51be",
"url": "/grafiti/index.html"
}
];
</code></pre>
<p>But I want it to also contain entries for these urls:</p>
<ul>
<li><code>/grafiti/icon-192.png</code></li>
<li><code>/grafiti/icon-512.png</code></li>
</ul>
<p>They come from the <code>public</code> folder.</p>
<p>Alternatively: How can I add my icons for the <code>manifest.webmanifest</code> file in the <code>src</code> folder in a way such that I can reference them from the web manifest?</p>
| 0debug
|
Routing between 2 LAN : <p>I have Mikrotik router with Wifi connected to:</p>
<ul>
<li>WAN/internet on port ether1.</li>
<li>Other ports are for LAN 10.0.1.*.</li>
<li>Only port ether8 is connected to another simple POE switch. Four IP cameras with static IP are connected. This is LAN2 192.168.50.*. Port is not included in bridge or switch.</li>
</ul>
<p><strong>From main LAN I can access internet and other PC on same LAN, but can't access IP cameras on LAN2.</strong> </p>
<p>So, what is wrong/missing in my Mikrotik configuration:</p>
<pre><code>/ip address
add address=10.0.1.1/24 comment="default configuration" interface= ether2-master-local network=10.0.1.0
add address=10.0.0.18/30 interface=ether1-gateway network=10.0.0.16
add address=192.168.50.253/24 interface=ether8-master-local-SUBNET network=
192.168.50.0
/ip route
add distance=2 gateway=10.0.0.17
</code></pre>
<p>No ping or trace route can reach LAN2 from main LAN.
If I connect to POE switch with my laptop and configure static IP in range 192.168.50.* than I can access all cameras OK.</p>
<p>If try ping IP camera directly from Mikrotik via ether8 than I get random mix of timeouts and success which is really strange.</p>
<p>Any help is appreciated.</p>
| 0debug
|
Is there a difference? : <p>Take the following code example</p>
<p>block 1</p>
<pre><code>var myObj = {}
if(true){
myObj = {
name: "John",
age: 54,
phone: "33333"
}
}else {
myObj = {
code: "E233",
qty: "34"
}
}
</code></pre>
<p>block 2</p>
<pre><code>if(true){
var myObj = {
name: "John",
age: 54,
phone: "33333"
}
}else {
var myObj = {
code: "E233",
qty: "34"
}
}
</code></pre>
<p>Is there a drawback in declaring variable <strong>myObj</strong> inside <strong>if/else</strong> statement?</p>
| 0debug
|
static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)
{
KVMState *s = kvm_state;
KVMSlot *mem, old;
int err;
MemoryRegion *mr = section->mr;
bool log_dirty = memory_region_is_logging(mr);
bool writeable = !mr->readonly && !mr->rom_device;
bool readonly_flag = mr->readonly || memory_region_is_romd(mr);
hwaddr start_addr = section->offset_within_address_space;
ram_addr_t size = int128_get64(section->size);
void *ram = NULL;
unsigned delta;
delta = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK));
delta &= ~TARGET_PAGE_MASK;
if (delta > size) {
return;
}
start_addr += delta;
size -= delta;
size &= TARGET_PAGE_MASK;
if (!size || (start_addr & ~TARGET_PAGE_MASK)) {
return;
}
if (!memory_region_is_ram(mr)) {
if (writeable || !kvm_readonly_mem_allowed) {
return;
} else if (!mr->romd_mode) {
add = false;
}
}
ram = memory_region_get_ram_ptr(mr) + section->offset_within_region + delta;
while (1) {
mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size);
if (!mem) {
break;
}
if (add && start_addr >= mem->start_addr &&
(start_addr + size <= mem->start_addr + mem->memory_size) &&
(ram - start_addr == mem->ram - mem->start_addr)) {
kvm_slot_dirty_pages_log_change(mem, log_dirty);
return;
}
old = *mem;
if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) || s->migration_log) {
kvm_physical_sync_dirty_bitmap(section);
}
mem->memory_size = 0;
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error unregistering overlapping slot: %s\n",
__func__, strerror(-err));
abort();
}
if (s->broken_set_mem_region &&
old.start_addr == start_addr && old.memory_size < size && add) {
mem = kvm_alloc_slot(s);
mem->memory_size = old.memory_size;
mem->start_addr = old.start_addr;
mem->ram = old.ram;
mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error updating slot: %s\n", __func__,
strerror(-err));
abort();
}
start_addr += old.memory_size;
ram += old.memory_size;
size -= old.memory_size;
continue;
}
if (old.start_addr < start_addr) {
mem = kvm_alloc_slot(s);
mem->memory_size = start_addr - old.start_addr;
mem->start_addr = old.start_addr;
mem->ram = old.ram;
mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering prefix slot: %s\n",
__func__, strerror(-err));
#ifdef TARGET_PPC
fprintf(stderr, "%s: This is probably because your kernel's " \
"PAGE_SIZE is too big. Please try to use 4k " \
"PAGE_SIZE!\n", __func__);
#endif
abort();
}
}
if (old.start_addr + old.memory_size > start_addr + size) {
ram_addr_t size_delta;
mem = kvm_alloc_slot(s);
mem->start_addr = start_addr + size;
size_delta = mem->start_addr - old.start_addr;
mem->memory_size = old.memory_size - size_delta;
mem->ram = old.ram + size_delta;
mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering suffix slot: %s\n",
__func__, strerror(-err));
abort();
}
}
}
if (!size) {
return;
}
if (!add) {
return;
}
mem = kvm_alloc_slot(s);
mem->memory_size = size;
mem->start_addr = start_addr;
mem->ram = ram;
mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering slot: %s\n", __func__,
strerror(-err));
abort();
}
}
| 1threat
|
static void qtrle_decode_32bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
{
int rle_code;
int pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char a, r, g, b;
unsigned int argb;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 4;
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (s->buf[stream_ptr++] - 1) * 4;
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(4);
a = s->buf[stream_ptr++];
r = s->buf[stream_ptr++];
g = s->buf[stream_ptr++];
b = s->buf[stream_ptr++];
argb = (a << 24) | (r << 16) | (g << 8) | (b << 0);
CHECK_PIXEL_PTR(rle_code * 4);
while (rle_code--) {
*(unsigned int *)(&rgb[pixel_ptr]) = argb;
pixel_ptr += 4;
}
} else {
CHECK_STREAM_PTR(rle_code * 4);
CHECK_PIXEL_PTR(rle_code * 4);
while (rle_code--) {
a = s->buf[stream_ptr++];
r = s->buf[stream_ptr++];
g = s->buf[stream_ptr++];
b = s->buf[stream_ptr++];
argb = (a << 24) | (r << 16) | (g << 8) | (b << 0);
*(unsigned int *)(&rgb[pixel_ptr]) = argb;
pixel_ptr += 4;
}
}
}
row_ptr += row_inc;
}
}
| 1threat
|
New to structs for C, can someone help me define these structs? : <p>Im still very new to C but slowly learning and I know how basic structs work, but Im learning about these new ones. How exactly do I use them and how do they work memory wise? </p>
<p>Would greatly appreciate it</p>
<p>struct within a struct??</p>
<pre><code>struct Multi {
int which;
union
{
float f;
double d;
int i;
} data;
};
</code></pre>
<p>struct pointing to itself?</p>
<pre><code>typedef struct Other {
double x;
int* y[2];
struct Other* z;
} Other;
</code></pre>
<p>this thing</p>
<pre><code>typedef int const * (* const CallMe)(const int *);
</code></pre>
<p>more </p>
<pre><code>typedef union {
void (*theta)();
void *(*iota)();
} Kappa;
</code></pre>
<p>Would greatly appreciate it. </p>
<p>If an example could be given like how to declare and initialize a single variable of that type, that would be great. I like working backkwards to try them out my self.</p>
| 0debug
|
the R has the warning written as -1. i do't understand : i am beginner in R , And understanding the pre-written code for data manipulation. I don't understand this one written line. can i get help around it? what does it signifies?
options(warn = -1)
| 0debug
|
Python interpret input as math function : <p>How do you turn a string gathered from input into an actual function? For example,</p>
<pre><code> >>>function = input("Enter a function: ")
>>>Enter a function: "sin(t)"
</code></pre>
<p>And then I'd be able to use the entered function. Is there a library to parse through the string and return a math function like so?</p>
| 0debug
|
Menu in android studio : I am new in android ,[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/6r917.jpg
I want to show this type of menu, when i clicked any item of menu, description of that item is shown in right panel. This menu always available on scree.
Which type of widget i have to use for this.
Thanks in advance
| 0debug
|
How to obtain the current url when while web-scraping? : <p>I am using scrapy for web scraping, and I want to store data to csv files. How do I obtain the current url so that I can use it to name my csv files? Using python 2.7.14, scrapy 1.5. Does scrapy provide any such functionality?</p>
| 0debug
|
void gdb_register_coprocessor(CPUState * env,
gdb_reg_cb get_reg, gdb_reg_cb set_reg,
int num_regs, const char *xml, int g_pos)
{
GDBRegisterState *s;
GDBRegisterState **p;
static int last_reg = NUM_CORE_REGS;
s = (GDBRegisterState *)g_malloc0(sizeof(GDBRegisterState));
s->base_reg = last_reg;
s->num_regs = num_regs;
s->get_reg = get_reg;
s->set_reg = set_reg;
s->xml = xml;
p = &env->gdb_regs;
while (*p) {
if (strcmp((*p)->xml, xml) == 0)
return;
p = &(*p)->next;
}
last_reg += num_regs;
*p = s;
if (g_pos) {
if (g_pos != s->base_reg) {
fprintf(stderr, "Error: Bad gdb register numbering for '%s'\n"
"Expected %d got %d\n", xml, g_pos, s->base_reg);
} else {
num_g_regs = last_reg;
}
}
}
| 1threat
|
static inline uint16_t get_hwc_color(SM501State *state, int crt, int index)
{
uint32_t color_reg = 0;
uint16_t color_565 = 0;
if (index == 0) {
return 0;
}
switch (index) {
case 1:
case 2:
color_reg = crt ? state->dc_crt_hwc_color_1_2
: state->dc_panel_hwc_color_1_2;
break;
case 3:
color_reg = crt ? state->dc_crt_hwc_color_3
: state->dc_panel_hwc_color_3;
break;
default:
printf("invalid hw cursor color.\n");
abort();
}
switch (index) {
case 1:
case 3:
color_565 = (uint16_t)(color_reg & 0xFFFF);
break;
case 2:
color_565 = (uint16_t)((color_reg >> 16) & 0xFFFF);
break;
}
return color_565;
}
| 1threat
|
Converting Julia jump to Python pulp : I stumbled upon a piece of software that I'd like to convert from Julia to Python (don't have much experience with either). I've spent a good amount of time on this section here and can't seem to get it working no matter what I do.
@defVar(m, used_team[i=1:num_teams], Bin)
@addConstraint(m, constr[i=1:num_teams], used_team[i] <= sum{skaters_teams[t, i]*skaters_lineup[t], t=1:num_skaters})
@addConstraint(m, constr[i=1:num_teams], sum{skaters_teams[t, i]*skaters_lineup[t], t=1:num_skaters} <= 6*used_team[i])
@addConstraint(m, sum{used_team[i], i=1:num_teams} == 3)
If you see any glaring errors here please let me know. I can also add all of the code I'm using if needed.
used_team = [LpVariable("y{}".format(i+1), 0, 1,cat = pulp.LpInteger) for i in range(num_teams)]
m += sum(u for u in(used_team)) == 3
for j, (x,z) in enumerate( zip(xs, skaters_teams[:])):
for i in range(num_teams):
m += sum(z[i]*x) >=ut[i]
m += sum(z[i]*x) <=6*ut[i]
| 0debug
|
Open file explorer to open any file via Excel-VBA : I have found code for this but have only found code that specifies excel files not one that allows me to open any document. Basically I have a button on a work sheet that needs to open a file explorer when clicked on. Once it has been clicked on it needs to direct the user to a specific file path that contains documents of every type. The user should then be able to open any of the documents.
Does anyone have a solution for this?
Thanks in advance!
| 0debug
|
UINavigationController Back button doesn't hide title on iOS 11 : <p>I've updated my device to iOS 11 Beta yesterday and my app using this code in AppDelegate for hide back button title on all screen:</p>
<pre><code>@implementation UINavigationItem (Customization)
/**
Removes text from all default back buttons so only the arrow or custom image shows up.
*/
-(UIBarButtonItem *)backBarButtonItem
{
return [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
</code></pre>
<p>It's working normally on older version but when I run my app on iOS 11 Beta, the title of back button still shown.
Does anyone face this problem? Is it a beta version bug of iOS or iOS 11 need another way to hide the back button title?</p>
| 0debug
|
static int usage(int ret)
{
fprintf(stderr, "dump (up to maxpkts) AVPackets as they are demuxed by libavformat.\n");
fprintf(stderr, "each packet is dumped in its own file named like `basename file.ext`_$PKTNUM_$STREAMINDEX_$STAMP_$SIZE_$FLAGS.bin\n");
fprintf(stderr, "pktdumper file [maxpkts]\n");
return ret;
}
| 1threat
|
static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
{
NBDClient *client = data->client;
char buf[8 + 8 + 8 + 128];
int rc;
const int myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
bool oldStyle;
qio_channel_set_blocking(client->ioc, false, NULL);
rc = -EINVAL;
TRACE("Beginning negotiation.");
memset(buf, 0, sizeof(buf));
memcpy(buf, "NBDMAGIC", 8);
oldStyle = client->exp != NULL && !client->tlscreds;
if (oldStyle) {
assert ((client->exp->nbdflags & ~65535) == 0);
TRACE("advertising size %" PRIu64 " and flags %x",
client->exp->size, client->exp->nbdflags | myflags);
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
stq_be_p(buf + 16, client->exp->size);
stw_be_p(buf + 26, client->exp->nbdflags | myflags);
} else {
stq_be_p(buf + 8, NBD_OPTS_MAGIC);
stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE);
}
if (oldStyle) {
if (client->tlscreds) {
TRACE("TLS cannot be enabled with oldstyle protocol");
goto fail;
}
if (nbd_negotiate_write(client->ioc, buf, sizeof(buf)) != sizeof(buf)) {
LOG("write failed");
goto fail;
}
} else {
if (nbd_negotiate_write(client->ioc, buf, 18) != 18) {
LOG("write failed");
goto fail;
}
rc = nbd_negotiate_options(client);
if (rc != 0) {
LOG("option negotiation failed");
goto fail;
}
assert ((client->exp->nbdflags & ~65535) == 0);
TRACE("advertising size %" PRIu64 " and flags %x",
client->exp->size, client->exp->nbdflags | myflags);
stq_be_p(buf + 18, client->exp->size);
stw_be_p(buf + 26, client->exp->nbdflags | myflags);
if (nbd_negotiate_write(client->ioc, buf + 18, sizeof(buf) - 18) !=
sizeof(buf) - 18) {
LOG("write failed");
goto fail;
}
}
TRACE("Negotiation succeeded.");
rc = 0;
fail:
return rc;
}
| 1threat
|
Swift/iOS13 - Access SceneDelegate window variable in a ViewController : <p>Is it possible to access window variable from SceneDelegate in a ViewController? Basically I need an alternative for this <code>UIApplication.shared.delegate.window</code> but can't find anything</p>
| 0debug
|
c# Abstract class calling an abstract method : Can anyone explain to me why this works the way it does. The output comes out to "Print This". But how does the base class call bar(), when there is no implementation
<i>
abstract class Base
{
protected virtual void foo()
{
bar();
}
protected abstract void bar();
}
class Sub:Program
{
protected override void foo()
{
base.foo();
}
protected override void bar()
{
Console.WriteLine("Print This");
}
static void Main(string[] args)
{
Sub obj = new Sub();
obj.foo();
}
}
</i>
| 0debug
|
Does 'for loop' is a function? : I was thinking about...
Does 'For loop' is a function? If not, what is it? How it works?
Example in C:
for(int i=0; i<32; i++)
{
...
}
Example in Python:
for i in range(0, 32):
print "..."
| 0debug
|
error is related to foreach in c# : using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Generic;
//using System.store.cs;
namespace _2ndprojecttry
{
public partial class Form1 : Form
{
store store = new store();
public List<item> insert= new List<item>();//this is the list of second list items
BindingSource itemslist = new BindingSource();
BindingSource selectitem2 = new BindingSource();
public Form1()
{
InitializeComponent();
setupdata();
itemslist.DataSource = store.items;
item.DataSource = itemslist;//linked between the two
// what to print inside
item.DisplayMember = "Display";
item.ValueMember = "Display";
//put the data to the selected item list
selectitem2.DataSource=insert;
selected_item.DataSource = selectitem2;
selected_item.DisplayMember = "Display";
selected_item.ValueMember = "Display";
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void setupdata()
{
store.vendors.Add(new vendor { firstname = "keshava",
lastname = "shourie",
commission = 0.5M });/* making keshava
* shourie as vendor 1*/
store.vendors.Add(new vendor { firstname = "varun",
lastname = "sharath",
commission = 0.5M });
//adding the lsit to the store
store.items.Add(new item {owner="harsha Bhogle",
title="sachin hero",
paymentdiscription=true,
price=5.0M,
// sold=false,
discription="about sachin"});
store.items.Add(new item
{
owner = "Arun Shourie",
title = "Democratic nation",
paymentdiscription = true,
price = 6.0M,
// sold=false,
discription = "about sachin"
});
//stores name
store.name = "shourie's shop";
}
private void cart_Click(object sender, EventArgs e)
{
//put the data to the selected item list
item selected = (item)item.SelectedItem;
insert.Add(selected);
selectitem2.ResetBindings(false);
// MessageBox.Show(selected.title);
}
private void purchase_Click(object sender, EventArgs e)
{
foreach (item item in selected_item)
{
}
}
}
}
I am getting an error related to foreach which states as,since i am not getting what to do with this error please suggest the changes to be made to improve and correct the error in the code.
Foreach statement cannot operate on type ' ' because it does not contain a public definition for 'GetEnumerator'.so please tell me what to implement so that i could get error freed code.
| 0debug
|
void ff_eac3_output_frame_header(AC3EncodeContext *s)
{
int blk, ch;
AC3EncOptions *opt = &s->options;
put_bits(&s->pb, 16, 0x0b77);
put_bits(&s->pb, 2, 0);
put_bits(&s->pb, 3, 0);
put_bits(&s->pb, 11, (s->frame_size / 2) - 1);
if (s->bit_alloc.sr_shift) {
put_bits(&s->pb, 2, 0x3);
put_bits(&s->pb, 2, s->bit_alloc.sr_code);
} else {
put_bits(&s->pb, 2, s->bit_alloc.sr_code);
put_bits(&s->pb, 2, 0x3);
}
put_bits(&s->pb, 3, s->channel_mode);
put_bits(&s->pb, 1, s->lfe_on);
put_bits(&s->pb, 5, s->bitstream_id);
put_bits(&s->pb, 5, -opt->dialogue_level);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 2, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
if (s->channel_mode > AC3_CHMODE_MONO) {
put_bits(&s->pb, 1, s->blocks[0].cpl_in_use);
for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) {
AC3Block *block = &s->blocks[blk];
put_bits(&s->pb, 1, block->new_cpl_strategy);
if (block->new_cpl_strategy)
put_bits(&s->pb, 1, block->cpl_in_use);
}
}
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++)
for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++)
put_bits(&s->pb, 2, s->exp_strategy[ch][blk]);
if (s->lfe_on) {
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++)
put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]);
}
for (ch = 1; ch <= s->fbw_channels; ch++)
put_bits(&s->pb, 5, 0);
put_bits(&s->pb, 6, s->coarse_snr_offset);
put_bits(&s->pb, 4, s->fine_snr_offset[1]);
put_bits(&s->pb, 1, 0);
}
| 1threat
|
TestFlight: Testers are not getting notified of new builds : <p>Since Apple moved to their new and improved TestFlight website, none of my internal or external users are receiving push notifications or emails when I make a new build available for testing.</p>
<p>These are testers who previously were getting push and emails with each new build.</p>
<p>If the tester goes to the TestFlight app on their device, they do see the new build is available for update there.</p>
<p>I see a couple threads about this in the Apple Developer forums but nobody seems to know how to work around this problem:</p>
<p><a href="https://forums.developer.apple.com/thread/76020" rel="noreferrer">https://forums.developer.apple.com/thread/76020</a></p>
<p><a href="https://forums.developer.apple.com/thread/76131" rel="noreferrer">https://forums.developer.apple.com/thread/76131</a></p>
<p>Anyone here found a workaround for this problem?</p>
| 0debug
|
MS Access VBA find login user Part 2 : I did my HW to find how get user login (AD not Admin db) for Access db using VBA, but i'm not sure why I don't see my function in Builder
I define function like in [enter link description here][1]
But somehow I can not see this function in my builder. What I'm missing. I plan to use this function to fill invisible txtBox in my form and log it into db. I'm on Office 2010. Sorry if I missed some basics, coiuld not find anywhere compele demo how to define and call function. Tx all
Public Function GetUser(Optional whatpart = "username")
Dim returnthis As String
If whatpart = "username" Then GetUser = Environ("USERNAME"): Exit Function
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.USERNAME)
Select Case whatpart
Case "fullname": returnthis = objUser.FullName
Case "firstname", "givenname": returnthis = objUser.givenName
Case "lastname": returnthis = objUser.LastName
Case Else: returnthis = Environ("USERNAME")
End Select
GetUser = returnthis
End Function
[![enter image description here][2]][2]
[1]: https://stackoverflow.com/questions/9052/is-there-a-way-for-ms-access-to-grab-the-current-active-directory-user
[2]: https://i.stack.imgur.com/XUOik.png
| 0debug
|
static void ehci_execute_complete(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
assert(p->async != EHCI_ASYNC_INFLIGHT);
p->async = EHCI_ASYNC_NONE;
DPRINTF("execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->usb_status);
if (p->usb_status < 0) {
switch (p->usb_status) {
case USB_RET_IOERROR:
case USB_RET_NODEV:
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR);
set_field(&q->qh.token, 0, QTD_TOKEN_CERR);
ehci_raise_irq(q->ehci, USBSTS_ERRINT);
break;
case USB_RET_STALL:
q->qh.token |= QTD_TOKEN_HALT;
ehci_raise_irq(q->ehci, USBSTS_ERRINT);
break;
case USB_RET_NAK:
set_field(&q->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT);
return;
case USB_RET_BABBLE:
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);
ehci_raise_irq(q->ehci, USBSTS_ERRINT);
break;
default:
fprintf(stderr, "USB invalid response %d\n", p->usb_status);
assert(0);
break;
}
} else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) {
p->usb_status = USB_RET_BABBLE;
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);
ehci_raise_irq(q->ehci, USBSTS_ERRINT);
} else {
if (p->tbytes && p->pid == USB_TOKEN_IN) {
p->tbytes -= p->usb_status;
} else {
p->tbytes = 0;
}
DPRINTF("updating tbytes to %d\n", p->tbytes);
set_field(&q->qh.token, p->tbytes, QTD_TOKEN_TBYTES);
}
ehci_finish_transfer(q, p->usb_status);
usb_packet_unmap(&p->packet, &p->sgl);
qemu_sglist_destroy(&p->sgl);
q->qh.token ^= QTD_TOKEN_DTOGGLE;
q->qh.token &= ~QTD_TOKEN_ACTIVE;
if (q->qh.token & QTD_TOKEN_IOC) {
ehci_raise_irq(q->ehci, USBSTS_INT);
}
}
| 1threat
|
setup customizable options for all simple products via db in magento 2 : <p>I would like to add the custom option for all simple products via db in magento 2 i can manually import the custom option for the first product one by one but there are 10k+ products so i can't do it. </p>
<p>I already check but find nothing, only a paid plugin for this</p>
| 0debug
|
React native expection java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/{package}/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit : <p>I am trying to integrate React Native with my existing Android App. I am getting the following exception, when initilizing React Native Screen:</p>
<blockquote>
<p>java.lang.UnsatisfiedLinkError: dlopen failed:
"/data/data/com.snapdeal.main/lib-main/libgnustl_shared.so" is 32-bit
instead of 64-bit</p>
</blockquote>
<p><em>The App is only crashing on 64-bit devices.</em> </p>
<p>As per my learning so far, I've found this <a href="https://github.com/oney/react-native-webrtc/issues/121" rel="noreferrer">issue</a> reported on React Native Repo, but the <a href="https://github.com/jitsi/jitsi-meet-react/commit/30a9ca40750f6a01a5eae0f8fa5c428ce541b147" rel="noreferrer">solution</a> suggested in this thread is not helpful as I am not using any external SO library in existing App.</p>
<p>Apart from above, I've realized another difference in library structure on the device where my App is installed. I am comparing structure of my App vs react native demo app. </p>
<p><strong>React demo App</strong></p>
<pre><code>root@generic_x86_64:**/data/data/com.react.demo/lib** # ls
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so
root@generic_x86_64:/data/data/**com.react.demo**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state
</code></pre>
<p><strong>My App</strong></p>
<pre><code>root@generic_x86_64:/data/data/**com.my.app**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so
</code></pre>
<p>Sharing few more details about my project:</p>
<p><strong>package.json</strong></p>
<pre><code>{
"name": "projectname",
"version": "1.0.0",
"description": "Native NPM",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"repository": {
"type": "git",
"url": ""
},
"author": "Ishan D",
"license": "ISC",
"dependencies": {
"react": "^15.3.2",
"react-native": "^0.37.0",
"react-native-linear-gradient": "^1.5.15",
"rn-viewpager": "^1.1.3"
},
"devDependencies": {}
}
</code></pre>
<p><strong>dependencies used in android native project</strong></p>
<pre><code>ext {
compileSdkVersion = 24
buildToolsVersion = '24.0.2'
minSdkVersion = 16
targetSdkVersion = 24
supportLibrariesVersion = '23.0.1'
playServiceVersion = '9.0.2'
dep = [
fabricPlugin : 'io.fabric',
fabricMavenUrl : 'https://maven.fabric.io/public',
fabricClasspath : 'io.fabric.tools:gradle:1.+',
playServiceClasspath : 'com.google.gms:google-services:1.3.0-beta1',
playServicePlugin : 'com.google.gms.google-services',
playServiceAppindexing: "com.google.android.gms:play-services-appindexing:$playServiceVersion",
playServiceLocation : "com.google.android.gms:play-services-location:$playServiceVersion",
playServiceVision : "com.google.android.gms:play-services-vision:$playServiceVersion",
playServiceAuth : "com.google.android.gms:play-services-auth:$playServiceVersion",
playServiceBase : "com.google.android.gms:play-services-base:$playServiceVersion",
playServiceIdentity : "com.google.android.gms:play-services-identity:$playServiceVersion",
playServiceAnalytics : "com.google.android.gms:play-services-analytics:$playServiceVersion",
playServiceGcm : "com.google.android.gms:play-services-gcm:$playServiceVersion",
underCouchClasspath : 'de.undercouch:gradle-download-task:2.0.0',
underCouchPluigin : 'de.undercouch.download',
crashlytics : 'com.crashlytics.sdk.android:crashlytics:2.4.0@aar',
moengage : 'com.moengage:moe-android-sdk:6.0.29',
supportV4 : "com.android.support:support-v4:$supportLibrariesVersion",
supportAppCompatV7 : "com.android.support:appcompat-v7:$supportLibrariesVersion",
supportCardviewV7 : "com.android.support:cardview-v7:$supportLibrariesVersion",
supportDesignV7 : "com.android.support:design:$supportLibrariesVersion",
okhttp : 'com.squareup.okhttp:okhttp:2.5.0',
junit : 'junit:junit:4.12',
mockito : 'org.mockito:mockito-core:1.10.19'
]
}
</code></pre>
<p>Any clue is appreciated. </p>
<p>PS: I know react-native does support 64-bit binaries and I am not using any external library.</p>
| 0debug
|
TypeError: login() takes 1 positional argument but 2 were given : <p>i have written a login view using buid in auth ,django auth.login() gives above error my code with error code o 500</p>
<pre><code>from rest_framework.response import Response
from rest_framework import status
from rest_framework.decorators import api_view
from django.contrib.auth.models import User
from django.contrib.auth import authenticate,logout,login
@api_view(['POST'])
def register(request):
user=User.objects.create_user(username=request.POST['username'],email=request.POST['email'],password=request.POST['password'])
return Response({'ok':'True'},status=status.HTTP_201_CREATED)
@api_view(['POST'])
def login(request):
user=authenticate(
username=request.POST['username'],
password=request.POST['password']
)
if user is not None:
login(request,user)
return Response({'ok':'True'},status=status.HTTP_200_OK)
else:
return Response({'ok':'False'},status=status.HTTP_401_UNAUTHORIZED)
</code></pre>
| 0debug
|
Why does SparkContext randomly close, and how do you restart it from Zeppelin? : <p>I am working in Zeppelin writing spark-sql queries and sometimes I suddenly start getting this error (after not changing code):</p>
<pre><code>Cannot call methods on a stopped SparkContext.
</code></pre>
<p>Then the output says further down:</p>
<pre><code>The currently active SparkContext was created at:
(No active SparkContext.)
</code></pre>
<p>This obviously doesn't make sense. Is this a bug in Zeppelin? Or am I doing something wrong? How can I restart the SparkContext?</p>
<p>Thank you</p>
| 0debug
|
static TCGv gen_muls_i64_i32(TCGv a, TCGv b)
{
TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64);
TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_ext_i32_i64(tmp1, a);
dead_tmp(a);
tcg_gen_ext_i32_i64(tmp2, b);
dead_tmp(b);
tcg_gen_mul_i64(tmp1, tmp1, tmp2);
return tmp1;
}
| 1threat
|
php, show position between students : I have school project which I have done almost to finish, but am stacking on how to show position of student in class according to highest total marks gets.
Here the table `(exam_record)` which contain some of records of marks. In this result I want to say John is in position `1` out of `3` students that all. any help please.
id name math history history geo pds average total_marks
003 John 90 100 90 100 88 93.6 468
002 Joan 100 60 70 83 90 60.6 403
005 Wily 80 58 90 60 90 75.6 378
| 0debug
|
Get Play store All search result with PHP scraper : **Summery :**
I want to fetch all Play store search result, problems is that, Apps that show after scroll that are not show in PHP file_get_content().
**Detail:**
I'm trying to make a php based play store scraper.
I check all stackoverflow answers and githup example, but they all are old, and not working,, Because previously Play store use "start" parameter for more apps/Next page.. Now play store show more apps on scroll
So after so many research, i decide to make my own scraper,
**What i am doing:**
file_get_contents() : to fetch the query url from play store
//i try with PHP:
$result = file_get_content( "https://play.google.com/store/search?q=football" );
// its only return 20 apps result, i want to get 250 result,..
Play store shows only 20 apps on the query result, more apps are shown ONLY on scrolling.
I try to get google ajax URL from "network tab", But google use token parameter for next scroll page...
**Question:**
**How i get scroll content with PHP.**
**How i get play store all search result.**
**How i fetch page content with PHP that show with js.**
| 0debug
|
Regular expression for remove empty tags except <script src="myjs.js"></script> : Can anyone help me with a javascript regular expression that remove all empty tags except script tag? I have tried the following expression, It removes script tags also.
var regex = new RegExp(/<([^\s>]+)[^>]*>\s*<\/\1>/gi);
| 0debug
|
int unix_connect(const char *path)
{
QemuOpts *opts;
int sock;
opts = qemu_opts_create(&dummy_opts, NULL, 0);
qemu_opt_set(opts, "path", path);
sock = unix_connect_opts(opts);
qemu_opts_del(opts);
return sock;
}
| 1threat
|
USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)
{
MSDState *s;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
const char *p1;
char fmt[32];
p1 = strchr(filename, ':');
if (p1++) {
const char *p2;
if (strstart(filename, "format=", &p2)) {
int len = MIN(p1 - p2, sizeof(fmt));
pstrcpy(fmt, len, p2);
drv = bdrv_find_format(fmt);
if (!drv) {
printf("invalid format %s\n", fmt);
return NULL;
}
} else if (*filename != ':') {
printf("unrecognized USB mass-storage option %s\n", filename);
return NULL;
}
filename = p1;
}
if (!*filename) {
printf("block device specification needed\n");
return NULL;
}
s = qemu_mallocz(sizeof(MSDState));
bdrv = bdrv_new("usb");
if (bdrv_open2(bdrv, filename, 0, drv) < 0)
goto fail;
s->bs = bdrv;
*pbs = bdrv;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
s->dev.handle_reset = usb_msd_handle_reset;
s->dev.handle_control = usb_msd_handle_control;
s->dev.handle_data = usb_msd_handle_data;
s->dev.handle_destroy = usb_msd_handle_destroy;
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)",
filename);
s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
fail:
qemu_free(s);
return NULL;
}
| 1threat
|
I am not able to install XAMPP on my system windows 7 32 bit : I am not able to install XAMPP on my system windows 7 32 bit ...the problem is after installing everything is working okay but appache is not running or starting..it is just showing notification that apache is starting but it never does ...I think My system is missing Port 80 which is used by Apache server to run ...even i checked it on my system but there is no such port 80 on my system
how to resolve this issue please somebody help me ASAP
| 0debug
|
symfony 4 - Multiple d'authentification : Good afternoon,
Here I am working on Symfony 4 and on the Symfony Security module.
I need to customize the authentication of my users without using plugins such as Fosuser.
This is for the following reasons:
The user connects to a "main" server (ldap) with his login/password
I need to be able to retrieve his credentials to test his account on other ldap servers in parallel.
When the user is authenticated on the main one, the user is redirected to a page telling him if everything is ok or not on the other servers. In case it is not, he has the possibility to update his account.
But the documentation deals with "simple" cases and here I am a little lost.
I tested several possibilities (authentication with Guard, test of creation of a personalized provider...) without results.
I would need to understand the mechanisms of symfony authentication to create a custom authentication.
If anyone has a lead to guide me, that would be great.
Thank you in advance.
| 0debug
|
swift i can't show or hide my label? : I have a HUGE problem.
What I wish for:
I wish for a label which is hidden and uneditable when the view loads or when pressing a button besides the button with the tag "15", and by pressing the button with the tag "15" is the only way for the label to show up and be editable.
my problem:
my problem is that when the view did load, it is not hidden at all and when I press the other buttons it doesn't hide either.
I have tried to set the "label.hidden = true"
inside the "weak var label : UILabel! {...}" (where I define the label) but when I then press the button with the tag "15" it doesn't show up.
btw don't worry about the other button tags, they are all included in the
"buttonAclicked" function, i have not included them because i thought it would take to much space
class TriangleViewController : UIViewController {
weak var label : UILabel! {
var label = UILabel(frame: CGRectMake(0 * view.bounds.width, 0.2 * view.bounds.height, 1 * view.bounds.width, 0.06 * view.bounds.height))
// label.center = CGPointMake(0.5 * view.bounds.width, 0.57 * view.bounds.height)
label.backgroundColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignment.Right
label.font = label.font.fontWithSize(28)
label.text = "0"
label.tag = 20
self.view.addSubview(label)
return label
}
override func viewDidLoad() {
label.hidden = true
}
func buttonAclicked(sender: UIButton) {
switch sender.tag {
case 11 :
print("det virker squ")
label.hidden = true
break
//MARK: KNAPPERNE P{ TREKANTERNE CASES
case 15 :
print("button A was pressed")
label.hidden = false
label.setNeedsDisplay()
activeInput = 1
break
case 16 :
print("button B was pressed")
label.hidden = true
activeInput = 2
break
case 17 :
print("button C was pressed")
activeInput = 3
break
case 18 :
print("button Y was pressed")
label.hidden = true
activeInput = 4
break
case 19 :
print("button X was pressed")
label.hidden = true
activeInput = 5
break
default :
print("wrong button")
activeInput = 0
}
}
}
| 0debug
|
GridPane - Xgap only on specific borders : Is there a way to apply the `Vgap` and `Hgap` properties of a `GridPane` only to specific borders? If no - is there a way to NOT apply it to the outer borders?
| 0debug
|
static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
const uint8_t *buf, int buf_size)
{
GetBitContext gb;
int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
int dts_flag = -1, cts_flag = -1;
int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
init_get_bits(&gb, buf, buf_size * 8);
if (sl->use_au_start)
au_start_flag = get_bits1(&gb);
if (sl->use_au_end)
au_end_flag = get_bits1(&gb);
if (!sl->use_au_start && !sl->use_au_end)
au_start_flag = au_end_flag = 1;
if (sl->ocr_len > 0)
ocr_flag = get_bits1(&gb);
if (sl->use_idle)
idle_flag = get_bits1(&gb);
if (sl->use_padding)
padding_flag = get_bits1(&gb);
if (padding_flag)
padding_bits = get_bits(&gb, 3);
if (!idle_flag && (!padding_flag || padding_bits != 0)) {
if (sl->packet_seq_num_len)
skip_bits_long(&gb, sl->packet_seq_num_len);
if (sl->degr_prior_len)
if (get_bits1(&gb))
skip_bits(&gb, sl->degr_prior_len);
if (ocr_flag)
skip_bits_long(&gb, sl->ocr_len);
if (au_start_flag) {
if (sl->use_rand_acc_pt)
get_bits1(&gb);
if (sl->au_seq_num_len > 0)
skip_bits_long(&gb, sl->au_seq_num_len);
if (sl->use_timestamps) {
dts_flag = get_bits1(&gb);
cts_flag = get_bits1(&gb);
}
}
if (sl->inst_bitrate_len)
inst_bitrate_flag = get_bits1(&gb);
if (dts_flag == 1)
dts = get_ts64(&gb, sl->timestamp_len);
if (cts_flag == 1)
cts = get_ts64(&gb, sl->timestamp_len);
if (sl->au_len > 0)
skip_bits_long(&gb, sl->au_len);
if (inst_bitrate_flag)
skip_bits_long(&gb, sl->inst_bitrate_len);
}
if (dts != AV_NOPTS_VALUE)
pes->dts = dts;
if (cts != AV_NOPTS_VALUE)
pes->pts = cts;
if (sl->timestamp_len && sl->timestamp_res)
avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);
return (get_bits_count(&gb) + 7) >> 3;
}
| 1threat
|
what are some free hosting servers to support Python : <p>I am trying to make an mobile application which requests the server to run the script, and then the python script does some scraping and returns the data to the application.</p>
<p>for testing purposes i have went through some free servers like <code>000webhost.com</code> , <code>Hostinger</code> and <code>Freehostia</code> but they doesn't seem to support python.</p>
<p>So.. any help with that?</p>
<p><strong>NOTE</strong><br>
I've went through <code>SL4A</code> and <code>Kivy</code> , but i want to approach this problem froma different way</p>
| 0debug
|
How to tell PHP to use SameSite=None for cross-site cookies? : <p>According to the article here <a href="https://php.watch/articles/PHP-Samesite-cookies" rel="noreferrer">https://php.watch/articles/PHP-Samesite-cookies</a> and PHP documenation at <a href="https://www.php.net/manual/en/session.security.ini.php" rel="noreferrer">https://www.php.net/manual/en/session.security.ini.php</a>, There are only 2 possible config options for this new feature, added in PHP 7.3:</p>
<ol>
<li>session.cookie_samesite=Lax</li>
<li>session.cookie_samesite=Strict</li>
</ol>
<p>Yet, according to the Chrome console, this needs to be set to "None":</p>
<blockquote>
<p>A cookie associated with a cross-site resource at URL was set without the <code>SameSite</code> attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with <code>SameSite=None</code> and <code>Secure</code>. You can review cookies in developer tools under Application>Storage>Cookies and see more details at URL and URL.</p>
</blockquote>
<p>Because of this, I can no longer set cross-site cookies. What is the workaround?</p>
| 0debug
|
static void pmac_ide_writew (void *opaque,
target_phys_addr_t addr, uint32_t val)
{
MACIOIDEState *d = opaque;
addr = (addr & 0xFFF) >> 4;
val = bswap16(val);
if (addr == 0) {
ide_data_writew(&d->bus, 0, val);
}
}
| 1threat
|
How to get submitted form data into a dynamically created csv with download button. : <p>Whenever user will submit form data then submitted form data will store in dynamically generated csv and user can able to download that csv. </p>
| 0debug
|
Error While publishing Azure Cloud service with .net 4.6 : <p>Error : "The feature named NetFx46 that is required by the uploaded package is not available in the OS * chosen for the deployment."</p>
| 0debug
|
Get solace message into sscanf : I am sending a message like this:
char buffer[175];
sprintf(buffer, "MD: %4ld %2d %10s %5s %7.2f %5d\n"
, id
, position
, *(MktDepthOperation::ENUMS) operation
, *(MktDeptSide::ENUMS)side
, price
, size
);
PrintProcessId, printf(buffer);
SolSendMessage("testhello", buffer);
...
void SolSendMessage(const char* topic, const char *text_p)
{
...
if (s_canSend) {
if ((rc = solClient_session_sendMsg(session_p, msg_p)) != SOLCLIENT_OK) {
...
}
On the sub side, I am just dumping the message. **How do I sscanf the fields back from the binary buffer that encodes the solace proprietary format?** I am trying to avoid `google protocol buffers` and using the recommended `Solace proprietary format`.
solClient_rxMsgCallback_returnCode_t
messageReceiveCallback ( solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p )
{
//printf ( "Received message:\n" );
solClient_msg_dump ( msg_p, NULL, 0 );
printf ( "\n" );
msgCount++;
return SOLCLIENT_CALLBACK_OK;
}
| 0debug
|
Is it possible to remove property from Custom Class in c# : <pre><code>public class abc
{
public int id{get;set;}
public string name{get;set;}
}
</code></pre>
<p>I want to remove property name from class abc dynamically. is it possible in c#?</p>
| 0debug
|
How to use glyphicons in this code below : <?php
$data = array(
'class'=>'btn btn-primary btn-lg btn-myblock',
'name'=>'signin',
'value'=>'Sign In'
);
?>
<?php echo form_submit($data); ?>
| 0debug
|
Making prolog predicates deterministic : <p>I've written a predicate, <code>shuffle/3</code>, which generates "shuffles" of two lists. When the second and third argument are instantiated, the first argument becomes a list which has all the elements of both Left and Right, in the same order that they appear in Left and Right.</p>
<p>For example:</p>
<pre><code>?- shuffle(X, [1, 2], [3, 4]).
X = [1, 3, 2, 4] ;
X = [1, 3, 4, 2] ;
X = [1, 2, 3, 4] ;
X = [3, 4, 1, 2] ;
X = [3, 1, 2, 4] ;
X = [3, 1, 4, 2] ;
false.
</code></pre>
<p>Here's the code I've come up with to implement it:</p>
<pre><code>shuffle([], [], []).
shuffle([H|R], [H|Left], Right) :- shuffle(R, Right, Left).
shuffle([H|R], Left, [H|Right]) :- shuffle(R, Right, Left).
</code></pre>
<p>This works well, and even generates reasonable results for "the most general query", but it fails to be deterministic for any query, even one where all arguments are fully instantiated: <code>shuffle([1, 2, 3, 4], [1, 2], [3, 4])</code>.</p>
<p>My real question is: is there anything I can do, while maintaining purity (so, no cuts), which makes this predicate deterministic when all arguments are fully instantiated?</p>
<p>And while I'm here, I'm new to Prolog, I wonder if anyone has advice on why I would care about determinism. Is it important for real prolog programs?</p>
| 0debug
|
How to bind dynamic data to ARIA-LABEL? : <p>I have dynamic text to bind to ARIA-LABEL on an html page.
This is an angular 2 app. I am using something like this:
aria-label="Product details for {{productDetails?.ProductName}}"</p>
<p>But I get an error -
Can't bind to 'aria-label' since it isn't a known property of 'div'. </p>
<p>Is there any workaround for this?</p>
| 0debug
|
int net_init_vde(QemuOpts *opts, const char *name, VLANState *vlan)
{
const char *sock;
const char *group;
int port, mode;
sock = qemu_opt_get(opts, "sock");
group = qemu_opt_get(opts, "group");
port = qemu_opt_get_number(opts, "port", 0);
mode = qemu_opt_get_number(opts, "mode", 0700);
if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
return -1;
}
return 0;
}
| 1threat
|
int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
struct kvm_s390_irq_state irq_state;
int r;
if (!kvm_check_extension(kvm_state, KVM_CAP_S390_IRQ_STATE)) {
return -ENOSYS;
}
if (cpu->irqstate_saved_size == 0) {
return 0;
}
irq_state.buf = (uint64_t) cpu->irqstate;
irq_state.len = cpu->irqstate_saved_size;
r = kvm_vcpu_ioctl(cs, KVM_S390_SET_IRQ_STATE, &irq_state);
if (r) {
error_report("Setting interrupt state failed %d", r);
}
return r;
}
| 1threat
|
Not nesting version of @atomic() in Django? : <p>From the <a href="https://docs.djangoproject.com/en/dev/topics/db/transactions/#django.db.transaction.atomic">docs of atomic()</a></p>
<blockquote>
<p>atomic blocks can be nested</p>
</blockquote>
<p>This sound like a great feature, but in my use case I want the opposite: I want the transaction to be durable as soon as the block decorated with <code>@atomic()</code> gets left successfully.</p>
<p>Is there a way to ensure durability in django's transaction handling?</p>
<h1>Background</h1>
<p>Transaction are ACID. The "D" stands for durability. That's why I think transactions can't be nested without loosing feature "D".</p>
<p>Example: If the inner transaction is successful, but the outer transaction is not, then the outer and the inner transaction get rolled back. The result: The inner transaction was not durable.</p>
<p>I use PostgreSQL, but AFAIK this should not matter much.</p>
| 0debug
|
static int virtio_blk_handle_scsi_req(VirtIOBlockReq *req)
{
int status = VIRTIO_BLK_S_OK;
struct virtio_scsi_inhdr *scsi = NULL;
VirtIODevice *vdev = VIRTIO_DEVICE(req->dev);
VirtQueueElement *elem = &req->elem;
VirtIOBlock *blk = req->dev;
#ifdef __linux__
int i;
VirtIOBlockIoctlReq *ioctl_req;
#endif
if (elem->out_num < 2 || elem->in_num < 3) {
status = VIRTIO_BLK_S_IOERR;
goto fail;
}
scsi = (void *)elem->in_sg[elem->in_num - 2].iov_base;
if (!blk->conf.scsi) {
status = VIRTIO_BLK_S_UNSUPP;
goto fail;
}
if (elem->out_num > 2 && elem->in_num > 3) {
status = VIRTIO_BLK_S_UNSUPP;
goto fail;
}
#ifdef __linux__
ioctl_req = g_new0(VirtIOBlockIoctlReq, 1);
ioctl_req->req = req;
ioctl_req->hdr.interface_id = 'S';
ioctl_req->hdr.cmd_len = elem->out_sg[1].iov_len;
ioctl_req->hdr.cmdp = elem->out_sg[1].iov_base;
ioctl_req->hdr.dxfer_len = 0;
if (elem->out_num > 2) {
ioctl_req->hdr.dxfer_direction = SG_DXFER_TO_DEV;
ioctl_req->hdr.iovec_count = elem->out_num - 2;
for (i = 0; i < ioctl_req->hdr.iovec_count; i++) {
ioctl_req->hdr.dxfer_len += elem->out_sg[i + 2].iov_len;
}
ioctl_req->hdr.dxferp = elem->out_sg + 2;
} else if (elem->in_num > 3) {
ioctl_req->hdr.dxfer_direction = SG_DXFER_FROM_DEV;
ioctl_req->hdr.iovec_count = elem->in_num - 3;
for (i = 0; i < ioctl_req->hdr.iovec_count; i++) {
ioctl_req->hdr.dxfer_len += elem->in_sg[i].iov_len;
}
ioctl_req->hdr.dxferp = elem->in_sg;
} else {
ioctl_req->hdr.dxfer_direction = SG_DXFER_NONE;
}
ioctl_req->hdr.sbp = elem->in_sg[elem->in_num - 3].iov_base;
ioctl_req->hdr.mx_sb_len = elem->in_sg[elem->in_num - 3].iov_len;
blk_aio_ioctl(blk->blk, SG_IO, &ioctl_req->hdr,
virtio_blk_ioctl_complete, ioctl_req);
return -EINPROGRESS;
#else
abort();
#endif
fail:
if (scsi) {
virtio_stl_p(vdev, &scsi->errors, 255);
}
return status;
}
| 1threat
|
React Native: How to Determine if Device is iPhone or iPad : <p>I know with React Native that we have the ability to determine whether iOS or Android is being run using the <code>Platform</code> module, but how can we determine what device is being used on iOS?</p>
| 0debug
|
How I Do SQL Server Column Auto Filter : Hello every one i need help how i filter SQL Server Column Data Filter Like all the word which starts from a Or A come on first line Like B or b come on the second ...
Create Table Table_my
(
C1 varchar(50)
, C2 varchar(50)
,
)
Select*
From Table_my
WHERE C1 Like '[ABC]%';
| 0debug
|
C - regcomp() failed with 'Success' : I'm trying to use a regex in order to validate a file-name.
Tried this string
"^(?!(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.[^.]*)?$)[^<>:\"/\\\|\\?*\x00-
\x1F]*[^<>:\"/\\\|\?*\x00-\x1F\\ .]$"
in online checker : https://www.freeformatter.com/regex-tester.html
Works as expected for 'video-'
-> Fully matches the source string!.
However, using:
bool regexCompile(regex_t ®ex, const char *pattern)
{
int res = 0;
res = regcomp(®ex, pattern, REG_EXTENDED);
printf("res = %d\n",res);
if(res) // regex compiled unsuccessfully
{
int rc;
char buffer[100];
regerror(rc, ®ex, buffer, 100);
printf("regcomp() failed with '%s'\n", buffer);
return false;
}
return true;
}
bool isValidFileName(const char *fileName)
{
regex_t regex;
int res = 0;
// regex not complete
const char* pattern = "^(?!(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\\.[^.]*)?$)[^<>:\"/\\\\|?*\x00-\x1F]*[^<>:\"/\\\\|\\?*\x00-\x1F\\ .]$";
if(regexCompile(regex, pattern) != true)
{
return false;
}
res = regexec(®ex, fileName, 0, NULL, 0);
if(!res)
{
return true;
}
return false;
}
I get for the filename "video-":
res = 13
regcomp() failed with 'Success'
0
any extra backslash need to be added in the c-regex version?
Thanks.
| 0debug
|
Xcode debugger not printing variables in some files : <p>I have an issue with the Xcode debugger. Everything works fine in general, I can print variables using <code>po <var></code> normally... Except in some files, where I can't print anything, and I have a <code>error: Couldn't apply expression side effects : couldn't get the data for variable self</code>
error in the console.</p>
<p><a href="https://i.stack.imgur.com/hbb3Q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hbb3Q.png" alt="Xcode debugger"></a></p>
<p>Weirdly, Xcode shows values correctly on the left debugger panel.</p>
<p>Does anyone have an idea?</p>
<p>Thanks!</p>
| 0debug
|
pyton insert to database only one data from tuple : I have a problem. I need parse muliple xml file and insert data to databaase.
`import os
from lxml import etree
import sqlite3
conn = sqlite3.connect("xml.db")
cursor = conn.cursor()
path = 'C:/tools/XML'
for filename in os.listdir(path):
fullname = os.path.join(path, filename)
tree = etree.parse(fullname)
test = tree.xpath('//*[@name="Name"]/text()')
tpl = tuple(test)
cursor.executemany("INSERT INTO parsee VALUES (?);", (tpl,))
conn.commit()
sql = "SELECT * FROM parsee"
cursor.execute(sql)
print(cursor.fetchall())`
result:
[('testname1',)]
if run program again that the program adds another same name.
restult:
[('testname1',),('testname1',)]
In folder 100 files:
<curent name="Name">testname1<curent>
<curent name="Name">testname2<curent>
<curent name="Name">testname3<curent>
<curent name="Name">testname4<curent>
| 0debug
|
field num_med cannot be modified : <p>I've put this code in a speedbutonclick but when I'was trying to execute it I got the message that said field num_med cannot be modified
the code is </p>
<pre><code> procedure TAddEdiMedForm.SpeedButton1Click(Sender: TObject);
begin
DM.MedicamentTable.InsertRecord([ Edit1.Text, Edit2.Text, Edit3.text,
Edit4.Text, Edit5.Text, Edit6.Text,
Edit7.Text]);
CloseModal;
end;
</code></pre>
| 0debug
|
static void do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
int index = qdict_get_int(qdict, "index");
if (mon_set_cpu(index) < 0)
qemu_error_new(QERR_INVALID_CPU_INDEX);
}
| 1threat
|
Find Max Id (Int Type) from JSON Array : <p>I am working in Aurelia.I want to get highest(max) Id in Integer type from json array .</p>
<pre><code>private list :any;
this.list = {
"a_Rows": [
{
"id": "1",
"sname": "amir",
"sType": "Cheque",
"semail": "ert",
},
{
"id" : "8",
"sname": "adil",
"sType": "Cheque1",
"semail": "abc",
}
]
</code></pre>
| 0debug
|
static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
int x, y;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (y = 0; y < 16; y++) {
for (x = 0; x < 16; x++) {
dst[x] += *coeffs;
coeffs++;
}
dst += stride;
}
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.