problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Xamarin, C#: Getting Push-Notifications, even when the app is killed : I am asking this AGAIN, because all answers seem to regard Java and not C#. So please, only answers in C# ;-).
Our app uses a server that can send out push notifications to a phone. But it can only do that, while the app is at least in the background. As soon as it is killed as a background task ( from the task manager) the notifications will no longer be delivered. But how is for instance WhatsApp doing that? When I am closing whatsapp from the task manager, I still get notificated about incoming messages.
Well, I though maybe a background service would help me out so this is what I have done so far:
private void StartServiceForPushs()
{
Intent intent = new Intent(this, typeof(Activity_MainMenu));
PendingIntent pendingIntent = PendingIntent.GetService(this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)GetSystemService(Context.AlarmService);
alarm.SetRepeating(AlarmType.RtcWakeup, TimeUtils.CurrentTimeMillis(), 1 * 60000, pendingIntent);
}
This should set up a service that checks for push notifications every 1 minute - but unfortunately, it does nothing. As soon as the app is closed completely, there are no more incomming messages. Can anyone help me out here?
Thanks! | 0debug |
Why won't my jquery work : <p>I have more code but this is the important bit. The rest of it is a JS function and styling.</p>
<pre><code> <button onClick="gB()" id="gb"> clickme</button>
<script src="jquery-1.12.2.min.js">
$( document ).ready(function() {
$('button').eq(0).trigger('click');
};
</code></pre>
| 0debug |
Application failed 2 times due to AM Container: exited with exitCode: 1 : <p>I ran a mapreduce job on hadoop-2.7.0 but mapreduce job can't be started and I faced with this bellow error:</p>
<pre><code>Job job_1491779488590_0002 failed with state FAILED due to: Application application_1491779488590_0002 failed 2 times due to AM Container for appattempt_1491779488590_0002_000002 exited with exitCode: 1
For more detailed output, check application tracking page:http://erfan:8088/cluster/app/application_1491779488590_0002Then, click on links to logs of each attempt.
Diagnostics: Exception from container-launch.
Container id: container_1491779488590_0002_02_000001
Exit code: 1
Stack trace: ExitCodeException exitCode=1:
at org.apache.hadoop.util.Shell.runCommand(Shell.java:545)
at org.apache.hadoop.util.Shell.run(Shell.java:456)
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:722)
at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:211)
at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)
at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Container exited with a non-zero exit code 1
Failing this attempt. Failing the application.
17/04/10 13:40:08 INFO mapreduce.Job: Counters: 0
</code></pre>
<p>What is the reason of this error and how can I solve this problem?</p>
<p>any help appreciated.</p>
| 0debug |
static void gen_ove_cy(DisasContext *dc, TCGv cy)
{
if (dc->tb_flags & SR_OVE) {
gen_helper_ove(cpu_env, cy);
}
}
| 1threat |
What are all the types of '✔️' characters available on Android ? (for a TextView) : <p>I wonder what are all the types of '✔️' characters available on Android (for a TextView)</p>
<p>Nota : I need to be able to change their color (I just saw that it is impossible to change the color for some of them)</p>
<p>Thanks !</p>
| 0debug |
How to hide/show on div click : I know if I look around I'll prolly find a solution but Its urgent so yeah here it goes,
I have a div that I'm tyring to show and hide on a click of another div
the code I'm using is :
`
$(document).ready(function(){
$(".logoo").click(function(){
$("ul.secondone").show(1000);
});
});
How do I add the hide function as well? I tried changing the .show to .hide but it didnt work.
Thanks for your patience, I'm still learning.
` | 0debug |
int smbios_entry_add(const char *t)
{
char buf[1024];
if (get_param_value(buf, sizeof(buf), "file", t)) {
struct smbios_structure_header *header;
struct smbios_table *table;
int size = get_image_size(buf);
if (size < sizeof(struct smbios_structure_header)) {
fprintf(stderr, "Cannot read smbios file %s", buf);
exit(1);
}
if (!smbios_entries) {
smbios_entries_len = sizeof(uint16_t);
smbios_entries = qemu_mallocz(smbios_entries_len);
}
smbios_entries = qemu_realloc(smbios_entries, smbios_entries_len +
sizeof(*table) + size);
table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
table->header.type = SMBIOS_TABLE_ENTRY;
table->header.length = cpu_to_le16(sizeof(*table) + size);
if (load_image(buf, table->data) != size) {
fprintf(stderr, "Failed to load smbios file %s", buf);
exit(1);
}
header = (struct smbios_structure_header *)(table->data);
smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY);
smbios_entries_len += sizeof(*table) + size;
(*(uint16_t *)smbios_entries) =
cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
return 0;
}
if (get_param_value(buf, sizeof(buf), "type", t)) {
unsigned long type = strtoul(buf, NULL, 0);
switch (type) {
case 0:
smbios_build_type_0_fields(t);
return 0;
case 1:
smbios_build_type_1_fields(t);
return 0;
default:
fprintf(stderr, "Don't know how to build fields for SMBIOS type "
"%ld\n", type);
exit(1);
}
}
fprintf(stderr, "smbios: must specify type= or file=\n");
return -1;
}
| 1threat |
void cpu_outl(CPUState *env, pio_addr_t addr, uint32_t val)
{
LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
ioport_write(2, addr, val);
#ifdef CONFIG_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
#endif
}
| 1threat |
How can we make kids timer : <p>I am trying to make a timer application which will visually show how much time left in a different color. Like this -</p>
<p><a href="https://i.stack.imgur.com/Vo9Xi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vo9Xi.png" alt="enter image description here"></a></p>
<p>I made the analog clock with my own view but no idea how can we make this color changing thing. If any body can give any suggestion or sample code that will be really great. I found one code but it's CoreDova I am doing it in native. <a href="https://github.com/shaungallagher/timer-for-kids" rel="nofollow noreferrer">https://github.com/shaungallagher/timer-for-kids</a></p>
| 0debug |
android _studio connect samsung phones : my ***SM-G360H*** phone only not working in android studio .Not connected
[**enter image description here**][1]
[1]: https://i.stack.imgur.com/IN3Qa.png | 0debug |
int net_init_dump(QemuOpts *opts, const char *name, VLANState *vlan)
{
int len;
const char *file;
char def_file[128];
assert(vlan);
file = qemu_opt_get(opts, "file");
if (!file) {
snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id);
file = def_file;
}
len = qemu_opt_get_size(opts, "len", 65536);
return net_dump_init(vlan, "dump", name, file, len);
}
| 1threat |
How I can iterate array with type NSString and type int. And get NSString element with lowest int? : I have some array with employees and their salary, I need iterate array and output one employee with lowest salary in all array.
//array
@property(strong,nonatomic) NSMutableArray<Employee *> *employees;
-(void) addEmployeeWithName:(NSString *)employeesName andLastName:(NSString *) employeesLastName andSalary:(int)employeesSalary;
//implementation of method
-(void) addEmployeeWithName:(NSString *)employeesName andLastName:(NSString *)employeesLastName andSalary:(int)employeesSalary
{
Employee *myEmp =[[Employee alloc] initWithFirstName:employeesName lastName:employeesLastName salary:employeesSalary];
[self.employees addObject:myEmp];
}
//In main() function something like this:
Employee *emp1 = [[Employee alloc] initWithFirstName:@"Bob" lastName:@"Lan" salary:1];
Employee *emp2 = [[Employee alloc] initWithFirstName:@"Ivan" lastName:@"Pal" salary:22]; | 0debug |
static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
ASFStream *stream;
AVCodecContext *codec;
uint32_t packet_number;
int64_t pts;
int start_sec;
int flags = pkt->flags;
int ret;
uint64_t offset = avio_tell(pb);
codec = s->streams[pkt->stream_index]->codec;
stream = &asf->streams[pkt->stream_index];
if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
flags &= ~AV_PKT_FLAG_KEY;
pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
av_assert0(pts != AV_NOPTS_VALUE);
pts *= 10000;
asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);
packet_number = asf->nb_packets;
put_frame(s, stream, s->streams[pkt->stream_index],
pkt->dts, pkt->data, pkt->size, flags);
start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)
/ ASF_INDEXED_INTERVAL);
if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {
uint16_t packet_count = asf->nb_packets - packet_number;
ret = update_index(s, start_sec, packet_number, packet_count, offset);
if (ret < 0)
return ret;
asf->end_sec = start_sec;
return 0;
| 1threat |
Car travel time between two points swift : <p>I am looking for something in swift that can give me the travel time (by car) of two coordinates. On some other threads, I have only seen suggestions to use external sources, but my question is, does apple have a built in feature to do this? Similarily, if there is not can someone please link a few external sources, as I have not found it (probably because I don't know exactly what I am looking for?</p>
<p>Thanks a lot.</p>
| 0debug |
static void ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=0; i<16; i++){
if(nnzc[ scan8[i] ])
ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride);
}
}
| 1threat |
void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
error_vreport(fmt, ap);
va_end(ap);
vdev->broken = true;
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
virtio_set_status(vdev, vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET);
virtio_notify_config(vdev);
}
}
| 1threat |
Minimum spec requirements for a phone for Android development : <p>To be a bit more specific to my case, I'm new to Android development, and I want an Android phone to properly test apps on. This phone would only be used for development, since I already have an iPhone for general use.</p>
<p>It only needs to be powerful enough to test small apps and 2D/3D games (I will likely upgrade in the future). My computer is pretty good, so I don't need to worry about my computer specs.</p>
<p>I'm not asking "which phone should I get", I already have one specific phone I want to buy, since it's on sale. I'm just unsure if it will be powerful enough. For reference, this is the phone I'm looking at: <a href="https://www.thinkofus.com.au/zte-shout-blade-a110-4g-unlocked-900-2100-3g-white" rel="nofollow noreferrer">https://www.thinkofus.com.au/zte-shout-blade-a110-4g-unlocked-900-2100-3g-white</a></p>
<p>Any answers are appreciated.</p>
| 0debug |
how would I use Javascript, html and css to produce the running tiger effect seen in run4tigers website? : <p>I wasn't sure if this question has already been asked before but I was wondering how you produce the interactive dotted text and the running tiger animation you see in the middle of the run4tiger website?
<a href="http://run4tiger.com/" rel="nofollow">http://run4tiger.com/</a>
Any information would be appreciated.</p>
| 0debug |
Posting objects to web worker using javascript : Excuse me for asking this question again but I don't get previous answers on this question or the answers is out dated.
So here we go again...
I have na array on objects, meshes created with Three.js, that I want to do some operations in a web worker. So the questions is how do I post them to the worker?
From what I understand there's something called Transferable Objects that uses something called arrayBuffer but I can't find any info about have to convert my array of objects to that. Or is this perhaps not possible?
Please help? | 0debug |
What does import from '@somefolder' do : I cloned a repo from [here.][1] And I found an import stat
import { NGSWUpdateService } from '@ngsw/ngsw-update.service';
I would like to state here that @ngsw is present inside my project's `src/client/app/shared/ngsw/ngsw-update.service`
But my question here is how does angular know where the ngsw folder is located and what is the role of `@` here I know that `~` means the root of the folder I'm working in but what does this `@` means and how does it work. I used to think that's something angular uses like @angular/core and other but its use in a local project is something not usual.
[1]: https://github.com/EreckGordon/angular-universal-pwa-starter-deploy | 0debug |
Enumerate Dictionary Iterating Key and Value : <p>I have a dictionary called <code>regionspointcount</code> that holds region names (<code>str</code>) as the keys and a count of a type of feature within that region (<code>int</code>) as the values e.g. <code>{'Highland':21}</code>.</p>
<p>I am wanting to iterate the key and value of dictionary while enumerating. Is there a way to do something like:</p>
<pre><code>for i, k, v in enumerate(regionspointcount.items()):
</code></pre>
<p>or do I have to resort to using a count variable?</p>
| 0debug |
Build system on Linux that doesn't rely on make : <p>In GNU/Linux the use of GNU <code>make</code> and Makefiles is very common but not entirely satisfying. I am aware of tools like <code>autotools</code> and <code>CMake</code> but ultimately they still generates a Makefile, (in the case of <code>CMake</code>)at least on Linux. It is just automating the process of generating the Makefile.</p>
<p>I am wondering what build systems there are on Linux that do not require one to execute GNU <code>make</code> or even have GNU <code>make</code> installed and what advandages/disadvantages they have compared to GNU <code>make</code>.</p>
<p>Similar information related to POSIX <code>make</code> or non-GNU Linux or Unix in general are also welcome. It would also be nice to include historical perspectives.</p>
| 0debug |
How to get value in a ListView according to position? : <p>I am trying to show database values into a Listview but, I set position of element manually (e.g. if(position==0){}) to do the intent to next activity. But i want to show these element according to their id, name, and mobile (i.e. for 1st element activity can parse these parameter to next activity, for 2nd parameters can hold their appropriate value...etc).
so how can i perform this!</p>
<p><strong>List.java</strong></p>
<pre><code> protected void showList(){
try {
JSONObject jsonObj = new JSONObject(myJSON);
peoples = jsonObj.getJSONArray(TAG_RESULTS);
for(int i=0;i<peoples.length();i++){
JSONObject c = peoples.getJSONObject(i);
String id = c.getString(TAG_ID);
String name = c.getString(TAG_NAME);
String mobile = c.getString(TAG_MOB);
HashMap<String,String> persons = new HashMap<String,String>();
persons.put(TAG_ID,id);
persons.put(TAG_NAME,name);
persons.put(TAG_MOB,mobile);
personList.add(persons);
}
ListAdapter adapter = new SimpleAdapter(
User_List.this, personList, R.layout.list_item,
new String[]{TAG_ID,TAG_NAME,TAG_MOB},
new int[]{R.id.id, R.id.name, R.id.mobile}
);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(position==0) {
Intent intent = new Intent(User_List.this, MapsActivity.class);
startActivity(intent);
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
</code></pre>
| 0debug |
static void test_drive_del_device_del(void)
{
qtest_start("-drive if=none,id=drive0,file=null-co:
" -device virtio-scsi-pci"
" -device scsi-hd,drive=drive0,id=dev0");
drive_del();
device_del();
qtest_end();
}
| 1threat |
vue webpack template missing parser : <p>I was just setting up a vue project using the webpack template like stated here: <a href="http://vuejs-templates.github.io/webpack/" rel="noreferrer">http://vuejs-templates.github.io/webpack/</a></p>
<p>However after running npm run dev just to test that the template is working, I get this error:</p>
<pre><code>Failed to compile with 2 errors 21:49:02
error in ./src/App.vue
Module build failed: Error: No parser and no file path given, couldn't infer a parser.
at normalize (path\node_modules\prettier\index.js:7051:13)
at formatWithCursor (path\node_modules\prettier\index.js:10370:12)
at path\node_modules\prettier\index.js:31115:15
at Object.format (path\node_modules\prettier\index.js:31134:12)
at Object.module.exports (path\node_modules\vue-loader\lib\template-compiler\index.js:80:23)
@ ./src/App.vue 11:0-354
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
error in ./src/components/HelloWorld.vue
Module build failed: Error: No parser and no file path given, couldn't infer a parser.
at normalize (path\node_modules\prettier\index.js:7051:13)
at formatWithCursor (path\node_modules\prettier\index.js:10370:12)
at path\node_modules\prettier\index.js:31115:15
at Object.format (path\node_modules\prettier\index.js:31134:12)
at Object.module.exports (path\node_modules\vue-loader\lib\template-compiler\index.js:80:23)
</code></pre>
<p>What am I doing wrong?</p>
| 0debug |
How to fix Missing Origin Validation error for "webpack-dev-server" in npm : <blockquote>
<p>npm audit</p>
</blockquote>
<pre><code> === npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
</code></pre>
<p>High Missing Origin Validation</p>
<p>Package webpack-dev-server</p>
<p>Patched in >=3.1.6</p>
<p>Dependency of laravel-mix [dev]</p>
<p>Path laravel-mix > webpack-dev-server</p>
<p>More info <a href="https://nodesecurity.io/advisories/725" rel="noreferrer">https://nodesecurity.io/advisories/725</a></p>
<p>found 1 high severity vulnerability in 11710 scanned packages
1 vulnerability requires manual review. See the full report for details.</p>
<p>How to fix this i cannot use laravel
whenever i try run command "npm run dev" it shows several problem</p>
| 0debug |
Not able to search for a specific sub-string in a given string - PYTHON : str_search = "DD09"
str_1 = "DD09 High speed status"
Str_2 = "Dd09 High speed status"
str.find (str_search)
print(str)
Output : DD09 High speed status
Why am not able to print Str_2 ? how to overcome this issue
Python New Bee here | 0debug |
Change android button drawable icon color programmatically : <p>I want to change my icon color from my button programmatically...</p>
<p>On my xml, i have:</p>
<pre><code> android:drawableTint="@color/colorPrimary"
android:drawableTop="@drawable/ic_car_black_24dp"
</code></pre>
<p>To set the icon and set the icon color... But i want to change the icon color from my java side...</p>
<p>Can someone help me?</p>
<pre><code> <android.support.v7.widget.AppCompatButton
android:id="@+id/bt_search_vehicle_car"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/eight_density_pixel"
android:layout_weight="1"
android:background="@drawable/background_rounded_blue_border"
android:drawableTint="@color/colorPrimary"
android:drawableTop="@drawable/ic_car_black_24dp"
android:padding="@dimen/eight_density_pixel"
android:text="Carros"
android:textAllCaps="false"
android:textColor="@color/colorPrimary" />
</code></pre>
| 0debug |
static void h261_encode_motion(H261Context * h, int val){
MpegEncContext * const s = &h->s;
int sign, code;
if(val==0){
code = 0;
put_bits(&s->pb,h261_mv_tab[code][1],h261_mv_tab[code][0]);
}
else{
if(val > 16)
val -=32;
if(val < -16)
val+=32;
sign = val < 0;
code = sign ? -val : val;
put_bits(&s->pb,h261_mv_tab[code][1],h261_mv_tab[code][0]);
put_bits(&s->pb,1,sign);
}
}
| 1threat |
START_TEST(qlist_destroy_test)
{
int i;
QList *qlist;
qlist = qlist_new();
for (i = 0; i < 42; i++)
qlist_append(qlist, qint_from_int(i));
QDECREF(qlist);
}
| 1threat |
void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
{
uint32_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le32(value);
fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| 1threat |
Phyton fibonacci unexpecred indent : Im new to code and learning python . I got homework to make print Fibonacci
numbers for N = 11 and N = 200 using method called Memoization . I found solution but when im running the code i getting two things : 1 .
Traceback (most recent call last):
**File "python", line 7
if n== 1:
^**
**IndentationError: unexpected indent**
and second i got empty result sometime when im running. what is wrong which the code :
def fibonacci (n) :
# If we have cached the value, then return it
if n in fibonacci_cache:
return fibonacci_cache[n]
# Compute the Nth term
if n== 1:
value = 1
elif n == 2:
value = 1
elif n > 2:
value = fibonacci(n-1) + fibonacci(n-2)
# Cache the value and return it
fibonacci_cache[n] = value
return value
print(n, ":", fibonacchi(11))
| 0debug |
intellij idea - Error: java: invalid source release 1.9 : <p>I'm trying to run my JSQL parser class, but I'm getting <code>Error: java: invalid source release 1.9</code>. </p>
<p>I tried to following <a href="https://stackoverflow.com/a/42650624/7327018">this answer</a>. I changed File> Build,Execution,Deployment> Java Compiler> Project bytecode version: 1.8. However, I can't change the Module language level and Project language level to 1.8 because there's not option for that. I still get the same error below.</p>
<p><strong>Error</strong>
<a href="https://i.stack.imgur.com/XlBuf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XlBuf.png" alt="enter image description here"></a></p>
<p><strong>Code</strong></p>
<pre><code>package cs4321.project2;
import java.io.FileReader;
import net.sf.jsqlparser.parser.CCJSqlParser;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.select.Select;
public class Parser {
private static final String queriesFile = "resources/input/queries.sql";
public static void main(String[] args) {
try {
CCJSqlParser parser = new CCJSqlParser(new FileReader(queriesFile));
Statement statement;
while ((statement = parser.Statement()) != null) {
System.out.println("Read statement: " + statement);
Select select = (Select) statement;
System.out.println("Select body is " + select.getSelectBody());
}
} catch (Exception e) {
System.err.println("Exception occurred during parsing");
e.printStackTrace();
}
}
}
</code></pre>
| 0debug |
Using Selenium how to get network request : <p>I want to take all the network request using selenium..I am not getting any way to find this solution.If anyone can suggest me or provide code or library that will be appreciated. </p>
<p><a href="https://i.stack.imgur.com/yzOUV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yzOUV.png" alt="Network Request"></a></p>
| 0debug |
In Java JDBC, access to the database table indicates the missing table, but the Navicat login database query data is normal : Is that jdbc4.0's Bug? The database is normal, official rpm
Compile and install | 0debug |
static void ppc_core99_init (int ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char **fd_filename, int snapshot,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char buf[1024];
qemu_irq *pic, **openpic_irqs;
int unin_memory;
int linux_boot, i;
unsigned long bios_offset, vga_bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
nvram_t nvram;
#if 0
MacIONVRAMState *nvr;
int nvram_mem_index;
#endif
m48t59_t *m48t59;
int vga_bios_size, bios_size;
qemu_irq *dummy_irq;
int pic_mem_index, dbdma_mem_index, cuda_mem_index;
int ide_mem_index[2];
int ppc_boot_device = boot_device[0];
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "default";
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
#if 0
env->osi_call = vga_osi_call;
#endif
qemu_register_reset(&cpu_ppc_reset, env);
register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
envs[i] = env;
}
if (env->nip < 0xFFF80000) {
cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
if (bios_size > 0x00080000) {
cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
vga_bios_offset = bios_offset + bios_size;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
if (vga_bios_size < 0) {
fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
vga_bios_size = 0;
} else {
phys_ram_base[vga_bios_offset] = 'N';
phys_ram_base[vga_bios_offset + 1] = 'D';
phys_ram_base[vga_bios_offset + 2] = 'R';
phys_ram_base[vga_bios_offset + 3] = 'V';
cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4),
vga_bios_size);
vga_bios_size += 8;
}
vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
if (kernel_size < 0) {
cpu_abort(env, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image(initrd_filename,
phys_ram_base + initrd_base);
if (initrd_size < 0) {
cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
isa_mem_base = 0x80000000;
isa_mmio_init(0xf2000000, 0x00800000);
unin_memory = cpu_register_io_memory(0, unin_read, unin_write, NULL);
cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
openpic_irqs[0] =
qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET];
break;
#if defined(TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET];
break;
#endif
default:
cpu_abort(env, "Bus model not supported on mac99 machine\n");
exit(1);
}
}
pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL);
pci_bus = pci_pmac_init(pic);
pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
ram_size, vga_ram_size,
vga_bios_offset, vga_bios_size);
dummy_irq = i8259_init(NULL);
serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
for(i = 0; i < nb_nics; i++) {
if (!nd_table[i].model)
nd_table[i].model = "ne2k_pci";
pci_nic_init(pci_bus, &nd_table[i], -1);
}
#if 1
ide_mem_index[0] = pmac_ide_init(&bs_table[0], pic[0x13]);
ide_mem_index[1] = pmac_ide_init(&bs_table[2], pic[0x14]);
#else
pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
#endif
cuda_init(&cuda_mem_index, pic[0x19]);
adb_kbd_init(&adb_bus);
adb_mouse_init(&adb_bus);
dbdma_init(&dbdma_mem_index);
macio_init(pci_bus, 0x0022, 0, pic_mem_index, dbdma_mem_index,
cuda_mem_index, NULL, 2, ide_mem_index);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, 3, -1);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
#if 0
nvr = macio_nvram_init(&nvram_mem_index, 0x2000);
pmac_format_nvram_partition(nvr, 0x2000);
macio_nvram_map(nvr, 0xFFF04000);
nvram.opaque = nvr;
nvram.read_fn = &macio_nvram_read;
nvram.write_fn = &macio_nvram_write;
#else
m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
#endif
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size,
ppc_boot_device, kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| 1threat |
static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
{
SchroEncoderParams *p_schro_params = avctx->priv_data;
SchroVideoFormatEnum preset;
schro_init();
p_schro_params->encoder = schro_encoder_new();
if (!p_schro_params->encoder) {
av_log(avctx, AV_LOG_ERROR,
"Unrecoverable Error: schro_encoder_new failed. ");
return -1;
}
preset = ff_get_schro_video_format_preset(avctx);
p_schro_params->format =
schro_encoder_get_video_format(p_schro_params->encoder);
schro_video_format_set_std_video_format(p_schro_params->format, preset);
p_schro_params->format->width = avctx->width;
p_schro_params->format->height = avctx->height;
if (set_chroma_format(avctx) == -1)
return -1;
if (avctx->color_primaries == AVCOL_PRI_BT709) {
p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV;
} else if (avctx->color_primaries == AVCOL_PRI_BT470BG) {
p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625;
} else if (avctx->color_primaries == AVCOL_PRI_SMPTE170M) {
p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525;
}
if (avctx->colorspace == AVCOL_SPC_BT709) {
p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV;
} else if (avctx->colorspace == AVCOL_SPC_BT470BG) {
p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV;
}
if (avctx->color_trc == AVCOL_TRC_BT709) {
p_schro_params->format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA;
}
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
&p_schro_params->frame_format) == -1) {
av_log(avctx, AV_LOG_ERROR,
"This codec currently supports only planar YUV 4:2:0, 4:2:2"
" and 4:4:4 formats.\n");
return -1;
}
p_schro_params->format->frame_rate_numerator = avctx->time_base.den;
p_schro_params->format->frame_rate_denominator = avctx->time_base.num;
p_schro_params->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
avctx->width,
avctx->height, 1);
if (!avctx->gop_size) {
schro_encoder_setting_set_double(p_schro_params->encoder,
"gop_structure",
SCHRO_ENCODER_GOP_INTRA_ONLY);
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->coder_type != FF_CODER_TYPE_VLC)
p_schro_params->noarith = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
schro_encoder_setting_set_double(p_schro_params->encoder,
"enable_noarith",
p_schro_params->noarith);
} else {
schro_encoder_setting_set_double(p_schro_params->encoder,
"au_distance", avctx->gop_size);
avctx->has_b_frames = 1;
p_schro_params->dts = -1;
}
if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
if (!avctx->global_quality) {
schro_encoder_setting_set_double(p_schro_params->encoder,
"rate_control",
SCHRO_ENCODER_RATE_CONTROL_LOSSLESS);
} else {
int quality;
schro_encoder_setting_set_double(p_schro_params->encoder,
"rate_control",
SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY);
quality = avctx->global_quality / FF_QP2LAMBDA;
if (quality > 10)
quality = 10;
schro_encoder_setting_set_double(p_schro_params->encoder,
"quality", quality);
}
} else {
schro_encoder_setting_set_double(p_schro_params->encoder,
"rate_control",
SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE);
schro_encoder_setting_set_double(p_schro_params->encoder,
"bitrate", avctx->bit_rate);
}
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)
schro_encoder_setting_set_double(p_schro_params->encoder,
"interlaced_coding", 1);
schro_encoder_setting_set_double(p_schro_params->encoder, "open_gop",
!(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP));
schro_video_format_set_std_signal_range(p_schro_params->format,
SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
schro_encoder_set_video_format(p_schro_params->encoder,
p_schro_params->format);
schro_debug_set_level(avctx->debug);
schro_encoder_start(p_schro_params->encoder);
ff_schro_queue_init(&p_schro_params->enc_frame_queue);
return 0;
}
| 1threat |
item in array wont increment : If there is a duplicate in an array, I want to increment the value. These are my console log results:
this is the map { '1': 1, '2': 1, '3': 1, '4': 2 }
this is the values more than one 4
this is iitem before 4
this is item after 5
this is iitem before 4
this is item after 5
this is the array here [ 1, 4, 2, 3, 4 ]
[ 1, 4, 2, 3, 4 ]
const incrementDuplicate = function(value, arr){
for(let item of arr){
if(item.toString() === value.toString()){
console.log('this is iitem before', item);
item = item+1;
console.log('this is item after', item)
}
}
return arr;
}
const uniqueArraySum = function(arr){
let map = {};
let newArray = [];
for(let item of arr){
if(!map[item]){
map[item] = 1;
} else{
map[item]++;
}
}
console.log('this is the map', map);
for(let item in map){
if(map[item] !== 1){
console.log('this is the values more than one', item);
newArray = incrementDuplicate(item, arr);
console.log('this is the array here', arr);
}
}
return newArray;
}
console.log(uniqueArraySum([1,4,2,3,4])); | 0debug |
PHP - on correct arrangement on spacing on php : Need help on aligning the space on php, when i try to output it for textfile. i always got this.
20FIRSTNAME1 LASTNAME1 LNUMBER1
20FIRSTNAME2 LASTNAME2 LNUMBER2
20FIRSTNAME3 LASTNAME3 LNUMBER3
The correct output must be this. it should be align.
20FIRSTNAME1 LASTNAME1 LNUMBER1
20FIRSTNAME2 LASTNAME2 LNUMBER2
20FIRSTNAME3 LASTNAME3 LNUMBER3
I used substr to output to it.
| 0debug |
How to get the file move process name/id : I want to move several files that names are saved in an `ObservableCollection<String> _collection` with this method:
string firstFolderThatContainsEveryFile = "...\Folder\Files";
string secondFolderArchiv = "...\Folder\Files\Archiv";
foreach (var item in _collection)
{
string firstFolder = System.IO.Path.Combine(firstFolderThatContainsEveryFile, item);
string secondFolder = System.IO.Path.Combine(secondFolderArchiv, item);
File.Move(firstFolder, secondFolder);
}
This works at the first time, but if i load new files into `firstFolderThatContainsEveryFile` and try to use my move method i get an exception:
> process is already in use
**How can i get the processname or processID to close the process before i use my move method, or is there even a better way to get around this?**
| 0debug |
Remove everything from string after the second - with a single line in Javascript : <p>I want to ensure the language is always extracted from a string, only before the 2nd dash (-)</p>
<p>So</p>
<p><code>en-AU-Option-A</code></p>
<p>becomes</p>
<p><code>en-AU</code></p>
<p>Is this possible with a single line of Javascript?</p>
| 0debug |
submit vs ngSubmit in Angular 2 : <p>In order to submit a form in Angular 2 we can either use form's "submit" or "ngSubmit" event.</p>
<pre><code><form #frm="ngForm" (submit)="add(frm.value)">
...
</form>
<form #frm="ngForm" (ngSubmit)="add(frm.value)">
...
</form>
</code></pre>
<p>Would like to know whats the difference between the two ?</p>
| 0debug |
static void tcx_update_display(void *opaque)
{
TCXState *ts = opaque;
ram_addr_t page, page_min, page_max;
int y, y_start, dd, ds;
uint8_t *d, *s;
void (*f)(TCXState *s1, uint8_t *dst, const uint8_t *src, int width);
if (ts->ds->depth == 0)
return;
page = ts->vram_offset;
y_start = -1;
page_min = 0xffffffff;
page_max = 0;
d = ts->ds->data;
s = ts->vram;
dd = ts->ds->linesize;
ds = 1024;
switch (ts->ds->depth) {
case 32:
f = tcx_draw_line32;
break;
case 15:
case 16:
f = tcx_draw_line16;
break;
default:
case 8:
f = tcx_draw_line8;
break;
case 0:
return;
}
for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE) {
if (cpu_physical_memory_get_dirty(page, VGA_DIRTY_FLAG)) {
if (y_start < 0)
y_start = y;
if (page < page_min)
page_min = page;
if (page > page_max)
page_max = page;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
} else {
if (y_start >= 0) {
dpy_update(ts->ds, 0, y_start,
ts->width, y - y_start);
y_start = -1;
}
d += dd * 4;
s += ds * 4;
}
}
if (y_start >= 0) {
dpy_update(ts->ds, 0, y_start,
ts->width, y - y_start);
}
if (page_min <= page_max) {
cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
} | 1threat |
Save java.time.LocalDate in Date column of DB2 database : <p>How to persist an item of <code>java.time.LocalDate</code> in a column of type <code>Date</code> within a DB2 database ?</p>
| 0debug |
How upload multiple files angular 7/8 using Queue with progress bar and create main progress bar for all files : I need multiple files to upload in angular 7/8 using queue with creating one progress bar to upload all files. | 0debug |
How to create funnel with event's parameter value in Firebase? : <p>I have a game with a lot of levels (Something like 2000). I want to create a funnel to see players' progression through these levels and balance out too-hard ones.</p>
<p>I cannot send an unique event for every level (e.g. "Level 0040 Completed") because
Firebase has a limit of 500 unique events. So I need to send an event like "Level Completed" and send the level number as parameter. But I don't know how can I create a funnel with that parameter. Is there any way to create funnel with a parameter of an event? </p>
| 0debug |
static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
{
MovieContext *movie = ctx->priv;
AVPacket *pkt = &movie->pkt;
enum AVMediaType frame_type;
MovieStream *st;
int ret, got_frame = 0, pkt_out_id;
AVFilterLink *outlink;
AVFrame *frame;
if (!pkt->size) {
if (movie->eof) {
if (movie->st[out_id].done) {
if (movie->loop_count != 1) {
ret = rewind_file(ctx);
if (ret < 0)
return ret;
movie->loop_count -= movie->loop_count > 1;
av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
return 0;
}
return AVERROR_EOF;
}
pkt->stream_index = movie->st[out_id].st->index;
} else {
ret = av_read_frame(movie->format_ctx, &movie->pkt0);
if (ret < 0) {
av_init_packet(&movie->pkt0);
*pkt = movie->pkt0;
if (ret == AVERROR_EOF) {
movie->eof = 1;
return 0;
}
return ret;
}
*pkt = movie->pkt0;
}
}
pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
movie->out_index[pkt->stream_index];
if (pkt_out_id < 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
return 0;
}
st = &movie->st[pkt_out_id];
outlink = ctx->outputs[pkt_out_id];
frame = av_frame_alloc();
if (!frame)
return AVERROR(ENOMEM);
frame_type = st->st->codec->codec_type;
switch (frame_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->st->codec, frame, &got_frame, pkt);
break;
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->st->codec, frame, &got_frame, pkt);
break;
default:
ret = AVERROR(ENOSYS);
break;
}
if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
av_frame_free(&frame);
av_free_packet(&movie->pkt0);
movie->pkt.size = 0;
movie->pkt.data = NULL;
return 0;
}
if (!ret || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
ret = pkt->size;
pkt->data += ret;
pkt->size -= ret;
if (pkt->size <= 0) {
av_free_packet(&movie->pkt0);
pkt->size = 0;
pkt->data = NULL;
}
if (!got_frame) {
if (!ret)
st->done = 1;
av_frame_free(&frame);
return 0;
}
frame->pts = av_frame_get_best_effort_timestamp(frame);
av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
describe_frame_to_str((char[1024]){0}, 1024, frame, frame_type, outlink));
if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (frame->format != outlink->format) {
av_log(ctx, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n",
av_get_pix_fmt_name(outlink->format),
av_get_pix_fmt_name(frame->format)
);
av_frame_free(&frame);
return 0;
}
}
ret = ff_filter_frame(outlink, frame);
if (ret < 0)
return ret;
return pkt_out_id == out_id;
}
| 1threat |
Python: rise over run slope calculator that outputs to feet and inches : I'm a first term Computer Science student, I'm attempting to write a rise over run calculator that can function as a construction calculator. Recieving input in feet and inches and outputs the slope in feet and inches to the nearest 1/16th.
what I have now can take an input in inches converted into a decimal and output the slope in the same format.
import sys
while (1):
print ("Enter the rise and run in inches to calculate slope.")
a = (input("First measurement is: "))
if (a == "stop"):
print ("goodbye")
sys.exit()
a= float (a)**2
b = float (input("second measurement is: "))**2
c = (float (a) + float (b))**(1/2)
print ("Slope is:", c,("inches"))
| 0debug |
static void pc_init1(MachineState *machine,
int pci_enabled,
int kvmclock_enabled)
{
PCMachineState *pc_machine = PC_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq *smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
if (machine->ram_size >= 0xe0000000) {
ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
above_4g_mem_size = machine->ram_size - lowmem;
below_4g_mem_size = lowmem;
} else {
above_4g_mem_size = 0;
below_4g_mem_size = machine->ram_size;
}
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
object_property_add_child(qdev_get_machine(), "icc-bridge",
OBJECT(icc_bridge), NULL);
pc_cpus_init(machine->cpu_model, icc_bridge);
if (kvm_enabled() && kvmclock_enabled) {
kvmclock_create();
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_acpi_build = has_acpi_build;
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, smbios_legacy_mode);
}
if (!xen_enabled()) {
fw_cfg = pc_memory_init(machine, system_memory,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
below_4g_mem_size,
above_4g_mem_size,
pci_memory, ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, system_io);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, gsi);
if (kvm_irqchip_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(isa_bus, cpu_irq[0]);
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
if (pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(),
0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, MAX_IDE_BUS);
if (pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
busname[4] = '0' + i;
idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
floppy, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled(false)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
gsi[9], *smi_irq,
kvm_enabled(), fw_cfg, &piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pc_machine->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pci_enabled) {
pc_pci_device_init(pci_bus);
}
}
| 1threat |
print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
{
char *errstr = NULL;
if (ret == -1) {
errstr = target_strerror(errno);
}
if ((ret == -1) && errstr) {
gemu_log(" = -1 errno=%d (%s)\n", errno, errstr);
} else {
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
}
}
| 1threat |
int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
{
float Lbuf[91][32][2];
float Rbuf[91][32][2];
const int len = 32;
int is34 = ps->is34bands;
top += NR_BANDS[is34] - 64;
memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
if (top < NR_ALLPASS_BANDS[is34])
memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
hybrid_analysis(Lbuf, ps->in_buf, L, is34, len);
decorrelation(ps, Rbuf, Lbuf, is34);
stereo_processing(ps, Lbuf, Rbuf, is34);
hybrid_synthesis(L, Lbuf, is34, len);
hybrid_synthesis(R, Rbuf, is34, len);
return 0;
}
| 1threat |
static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
int16_t *dstV,
const uint8_t *src,
int width,
enum AVPixelFormat origin,
int shr, int shg,
int shb, int shp,
int maskr, int maskg,
int maskb, int rsh,
int gsh, int bsh, int S,
int32_t *rgb2yuv)
{
const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
maskgx = ~(maskr | maskb);
const unsigned rnd = (256U<<(S)) + (1<<(S-6));
int i;
maskr |= maskr << 1;
maskb |= maskb << 1;
maskg |= maskg << 1;
for (i = 0; i < width; i++) {
int px0 = input_pixel(2 * i + 0) >> shp;
int px1 = input_pixel(2 * i + 1) >> shp;
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
int rb = px0 + px1 - g;
b = (rb & maskb) >> shb;
if (shp ||
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
g >>= shg;
} else {
g = (g & maskg) >> shg;
}
r = (rb & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
}
}
| 1threat |
What is the recommended approach for compiling LESS files in a Spring Boot web app? : <p>What tools are recommended for comping LESS files into CSS within a Spring Boot web app? I am using Thymeleaf and Maven and I am setting up a sample project. I wanted to import my current project's LESS files in to this sample project. Thanks for any recommendations.</p>
| 0debug |
static void free_device_list(AVOpenCLDeviceList *device_list)
{
int i, j;
if (!device_list)
return;
for (i = 0; i < device_list->platform_num; i++) {
if (!device_list->platform_node[i])
continue;
for (j = 0; j < device_list->platform_node[i]->device_num; j++) {
av_freep(&(device_list->platform_node[i]->device_node[j]->device_name));
av_freep(&(device_list->platform_node[i]->device_node[j]));
}
av_freep(&device_list->platform_node[i]->device_node);
av_freep(&(device_list->platform_node[i]->platform_name));
av_freep(&device_list->platform_node[i]);
}
av_freep(&device_list->platform_node);
device_list->platform_num = 0;
}
| 1threat |
Why does the value of mycounter[0] change when myCounters[2] is reset? (Theory) : <p>This is supposed to happen for the task that I'm currently doing, but I don't understand why this is taking place. When <code>myCounter[2].Reset()</code> is called it resets the values of both myCounters[0] and myCounters[2]. Why is this occuring</p>
<p>Program.cs</p>
<pre><code>namespace CounterTest
{
public class MainClass
{
private static void PrintCounters(Counter[] counters)
{
foreach ( Counter c in counters)
{
Console.WriteLine("Name is: {0} Value is: {1}", c.Name, c.Value);
}
}
public static void Main(string[] args)
{
Counter[] myCounters = new Counter[3];
myCounters[0] = new Counter("Counter 1");
myCounters[1] = new Counter("Counter 2");
myCounters[2] = myCounters[0];
for (int i=0; i<4 ; i++)
{
myCounters[0].Increment();
}
for (int i = 0; i < 9; i++)
{
myCounters[1].Increment();
}
MainClass.PrintCounters(myCounters);
myCounters[2].Reset();
MainClass.PrintCounters(myCounters);
}
}
}
</code></pre>
<p>Class1.cs</p>
<pre><code>namespace CounterTest
{
public class Counter
{
private int _count;
public int Value
{
get
{return _count;}
}
private string _name;
public string Name
{
get {return _name; }
set {_name = value; }
}
public Counter(string Name)
{
_name = Name;
_count = 0;
}
public void Increment()
{ _count = _count + 1; }
public void Reset()
{_count = 0;}
}
}
</code></pre>
<p>The output is:</p>
<p>Name is: Counter 1 Value is: 4</p>
<p>Name is: Counter 2 Value is: 9</p>
<p>Name is: Counter 1 Value is: 4</p>
<p>Name is: Counter 1 Value is: 0</p>
<p>Name is: Counter 2 Value is: 9</p>
<p>Name is: Counter 1 Value is: 0</p>
<p>Thank you for any help.</p>
| 0debug |
Error: incompatible types --> need an answer tonight :( : public void init() {
Container cp = getContentPane();
cp.setLayout(null);
cp.setBounds(0, 0, 769, 556);
cp.setBackground(Color.ORANGE);
// Begin componenten
String arrayWoord[]=new String[10];
arrayWoord[0] = letterVeld1;
arrayWoord[1] = letterVeld2;
arrayWoord[2] = letterVeld3;
arrayWoord[3] = letterVeld4;
arrayWoord[4] = letterVeld5;
arrayWoord[5] = letterVeld6;
arrayWoord[6] = letterVeld7;
arrayWoord[7] = letterVeld8;
arrayWoord[8] = letterVeld9;
arrayWoord[9] = letterVeld10;
Could someone help me? Java gives the following error multiple times:
Compileer C:\java\Javaeditor\Java\Project\GalgjeApplet\GalgjeApplet.java met
Java-Compiler
GalgjeApplet.java:77:21: error: incompatible types
arrayWoord[0] = letterVeld1;
^
required: String
found: JTextField
I have to submit my code tonight so a quick answer should really help me! :) | 0debug |
OffsetDateTime to milliseconds : <p>I want to know if there is a way to convert <code>java.time.OffsetDateTime</code> to Milliseconds, I found this way, but I don't know if it is the best one:</p>
<pre><code>book.getInteractionDuration().getStartTimeStamp().toEpochSecond()*1000
</code></pre>
| 0debug |
styling the footer changes header parent element : <p>I am new to the front end stuff and having a bit of a moment endeavouring to style the footer on my project. </p>
<p>My header and footer are both constructed using a ( UL LI and UL LI a )</p>
<p>Problem: When I try and style the footer using CSS the header is also correspondingly changed with the same styling.</p>
<p>How should I modify the footer in terms of coding so that when I apply styling to it, it does not change the header/parent element.</p>
<p><a href="https://i.stack.imgur.com/cGbXN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cGbXN.jpg" alt="enter image description here"></a></p>
<blockquote>
<p>Header</p>
</blockquote>
<pre><code><nav class="navbar navbar-static-top navbar-default" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img alt="Nippon Beauty" class="navbar-brand-icon" src="assets/nippon.svg">
</a>
</div>
<!--<span style="color: #53100e">| Japanese and South Korean Luxury Skincare</span>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Login", new_user_session_path %></li>
<li><%= link_to "Signup", new_user_registration_path %></li>
<% if user_signed_in? %>
<li><%= link_to "Account Settings", edit_user_registration_path %></li>
<li><%= link_to "Log out", destroy_user_session_path, method: :delete %></li>
<% else %>
<% end %>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</code></pre>
<blockquote>
<p>Footer</p>
</blockquote>
<pre><code><div class="row bottom-footer text-center-mobile">
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Returns Policy</a></li>
<li><a href="#">Terms and Conditions</a></li>
<li><a href="#">Privacy Policy</a></li>
<li><a href="#">FAQ</a></li>
</ul>
</div>
</code></pre>
<blockquote>
<p>CSS</p>
</blockquote>
<pre><code>@import url(https://fonts.googleapis.com/css?family=Lato:400,700);
$body-bg: #ecf0f1;
$font-family-sans-serif: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
$navbar-height: 70px;
$navbar-default-bg: white;
$navbar-default-brand-color: #c0392b;
$brand-primary: #c0392b;
$jumbotron-bg: white;
@import 'bootstrap';
@import 'bootstrap-sprockets';
.center {
text-align: center;
}
.navbar-brand {
font-weight: bold;
}
.btn-lg {
padding: 18px 28px;
font-size: 22px;
border-radius: 8px;
}
.jumbotron {
width: 735px;
padding-left: 30px;
padding-right: 15px;
padding-bottom: 20px;
padding-top: 20px;
}
.container .jumbotron {
border-radius: 35px;
}
.container {
width: 1270px;
}
.navbar {
min-height: 90px;
}
.navbar-brand {
float: left;
padding: 10px 15px;
font-size: 14px;
font-weight: normal;
}
.navbar-brand img {
display: inline-block;
}
.navbar-brand span {
display:inline-block;
vertical-align : middle;
height: 7px;
}
h1, {
font-family: 'Lobster', cursive;
color: #e22f8f;
}
.row {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1rem;
background-color: #efefef;
text-align: center;
}
li {
display: inline-block;
*display: inline;
padding: 4px;
color: #e22f8f;
}
</code></pre>
| 0debug |
Constructing a transition matrix from two vectors in R : <p>I am trying to visualize the transition frequency of a process. I have the following data></p>
<pre><code>from to
1 4
4 5
1 3
1 3
4 5
...
</code></pre>
<p>What I am trying to do is create a heatmap of frequency matrix of those transitions, so for upper example, </p>
<pre><code> 1 3 4 5
1 0 2 1 0
3 0 0 0 0
4 0 0 0 2
5 0 0 0 0
</code></pre>
<p>Before I reinvent the wheel, are there any predefined functions in R, which could give me such result?</p>
<p>Thanks!</p>
| 0debug |
static int usb_hub_initfn(USBDevice *dev)
{
USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
USBHubPort *port;
int i;
s->dev.speed = USB_SPEED_FULL;
for (i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
usb_register_port(usb_bus_from_device(dev),
&port->port, s, i, &s->dev, usb_hub_attach);
port->wPortStatus = PORT_STAT_POWER;
port->wPortChange = 0;
}
return 0;
}
| 1threat |
static int load_textfile(AVFilterContext *ctx)
{
DrawTextContext *s = ctx->priv;
int err;
uint8_t *textbuf;
size_t textbuf_size;
if ((err = av_file_map(s->textfile, &textbuf, &textbuf_size, 0, ctx)) < 0) {
av_log(ctx, AV_LOG_ERROR,
"The text file '%s' could not be read or is empty\n",
s->textfile);
return err;
}
if (!(s->text = av_realloc(s->text, textbuf_size + 1)))
return AVERROR(ENOMEM);
memcpy(s->text, textbuf, textbuf_size);
s->text[textbuf_size] = 0;
av_file_unmap(textbuf, textbuf_size);
return 0;
}
| 1threat |
Create kubernetes pod with volume using kubectl run : <p>I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command:</p>
<pre><code>kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash
</code></pre>
<p>But the volume does not appear in the interactive bash.</p>
<p>Is there a better way to create a pod with volume that you can attach to?</p>
| 0debug |
C# Next Day of Week Logic : <p>I am having some issues making this code more efficient; I am writing a basic scheduler and want to know the number of days between the next run from the current day. What I have works, but it seems huge for a simple task? </p>
<p>I set the days of the week I would like using bools in a class...</p>
<p>This is what I have:</p>
<pre><code>class Schedule
{
public string StartTime;
public bool Monday;
public bool Tuesday;
public bool Wednesday;
public bool Thursday;
public bool Friday;
public bool Saturday;
public bool Sunday;
}
Schedule jobSchedule = new Schedule();
jobSchedule.Monday = true;
jobSchedule.Tuesday = true;
jobSchedule.Wednesday = false;
jobSchedule.Thursday = true;
jobSchedule.Friday = true;
jobSchedule.Saturday = true;
jobSchedule.Sunday = true;
</code></pre>
<p>This sets up when I would like the code to run. What I would like now is a function to return an int of the number of days to the next execution... I have the following:</p>
<pre><code> private int nextDay()
{
int days = 0;
DayOfWeek dow = DateTime.Now.DayOfWeek;
switch (dow)
{
case DayOfWeek.Monday:
if (jobSchedule.Tuesday) {
days += 1;
} else if (jobSchedule.Wednesday) {
days += 2;
} else if (jobSchedule.Thursday) {
days += 3;
} else if (jobSchedule.Friday) {
days += 4;
} else if (jobSchedule.Saturday) {
days += 5;
} else if (jobSchedule.Sunday) {
days += 6;
}
break;
case DayOfWeek.Tuesday:
if (jobSchedule.Wednesday)
{
days += 1;
}
else if (jobSchedule.Thursday)
{
days += 2;
}
else if (jobSchedule.Friday)
{
days += 3;
}
else if (jobSchedule.Saturday)
{
days += 4;
}
else if (jobSchedule.Sunday)
{
days += 5;
}
else if (jobSchedule.Monday)
{
days += 6;
}
break;
case DayOfWeek.Wednesday:
if (jobSchedule.Thursday)
{
days += 1;
}
else if (jobSchedule.Friday)
{
days += 2;
}
else if (jobSchedule.Saturday)
{
days += 3;
}
else if (jobSchedule.Sunday)
{
days += 4;
}
else if (jobSchedule.Monday)
{
days += 5;
}
else if (jobSchedule.Tuesday)
{
days += 6;
}
break;
case DayOfWeek.Thursday:
if (jobSchedule.Friday)
{
days += 1;
}
else if (jobSchedule.Saturday)
{
days += 2;
}
else if (jobSchedule.Sunday)
{
days += 3;
}
else if (jobSchedule.Monday)
{
days += 4;
}
else if (jobSchedule.Tuesday)
{
days += 5;
}
else if (jobSchedule.Wednesday)
{
days += 6;
}
break;
case DayOfWeek.Friday:
if (jobSchedule.Saturday)
{
days += 1;
}
else if (jobSchedule.Sunday)
{
days += 2;
}
else if (jobSchedule.Monday)
{
days += 3;
}
else if (jobSchedule.Tuesday)
{
days += 4;
}
else if (jobSchedule.Wednesday)
{
days += 5;
}
else if (jobSchedule.Thursday)
{
days += 6;
}
break;
case DayOfWeek.Saturday:
if (jobSchedule.Sunday)
{
days += 1;
}
else if (jobSchedule.Monday)
{
days += 2;
}
else if (jobSchedule.Tuesday)
{
days += 3;
}
else if (jobSchedule.Wednesday)
{
days += 4;
}
else if (jobSchedule.Thursday)
{
days += 5;
}
else if (jobSchedule.Friday)
{
days += 6;
}
break;
case DayOfWeek.Sunday:
if (jobSchedule.Monday)
{
days += 1;
}
else if (jobSchedule.Tuesday)
{
days += 2;
}
else if (jobSchedule.Wednesday)
{
days += 3;
}
else if (jobSchedule.Thursday)
{
days += 4;
}
else if (jobSchedule.Friday)
{
days += 5;
}
else if (jobSchedule.Saturday)
{
days += 6;
}
break;
}
return days;
}
</code></pre>
<p>How could I shorted this down? The above works how I want it but seems too much :(</p>
<p>Thanks for any help.</p>
| 0debug |
Shared component library best practices : <p>I am creating a shareable React component library. </p>
<p>The library contains many components but the end user may only need to use a few of them. </p>
<p>When you bundle code with Webpack (or Parcel or Rollup) it creates one single file with <em>all the code</em>. </p>
<p>For performance reasons I do not want to all that code to be downloaded by the browser unless it is actually used.
Am I right in thinking that I should not bundle the components? Should the bundling be left to the consumer of the components?
Do I leave anything else to the consumer of the components? Do I just transpile the JSX and that's it?</p>
<p>If the same repo contains lots of different components, what should be in main.js?</p>
| 0debug |
Comparing Time - Python : <p>I have a function where I read the time from a file. I put this into a variable. I then subtract this value from the current time which most of the time will give me a value around . </p>
<p>My problem is im not sure how to check if this value which I attach to a variable is greater than say 20 seconds. </p>
<pre><code>def numberchecker():
with open('timelog.txt', 'r') as myfile:
data=myfile.read().replace('\n','')
a = datetime.strptime(data,'%Y-%m-%d %H:%M:%S.%f')
b = datetime.now()
c = b-a (This outputs for example: 0:00:16.657538)
d = (would like this to a number I set for example 25 seconds)
if c > d:
print ("blah blah")
</code></pre>
| 0debug |
Bukkit coding - Where will I put the if.senderHasPermission? : Where will i put the permission line in my plugin command code?
http://pastebin.com/BCLyr0Mn
| 0debug |
Unknown mistake : A small game that guesses numbers, but there are the following errors in pycharm, opening with IDLE is no problem. May I ask what is the reason?
[enter image description here][1]
[enter image description here][2]
[enter image description here][3]
[1]: https://i.stack.imgur.com/PdZGu.png
[2]: https://i.stack.imgur.com/LR3FB.png
[3]: https://i.stack.imgur.com/WxUxl.png | 0debug |
How do I create a file in the same directory as the executable when run by root? : <p>I have a program written in C that creates and reads a config file. It assumes that the config file is in the same directory as it is.</p>
<p>The program is run by fcron as root. If root runs this program, then the config file is created in root's home directory. It needs to be created in the user's directory where the program is.</p>
<p>I don't know enough about user management in linux to solve this, so the only way I can think to solve this is to get the executable's path by modifying argv[0].</p>
<p>Is there a better way?</p>
| 0debug |
systemctl status shows inactive dead : <p>I am trying to write my own (simple) systemd service which does something simple.( Like writing numbers 1 to 10 to a file, using the shell script).
My service file looks like below.</p>
<pre><code>[Unit]
Description=NandaGopal
Documentation=https://google.com
After=multi-user.target
[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/hello.sh &
[Install]
RequiredBy = multi-user.target
</code></pre>
<p>This is my shell script.</p>
<pre><code>#!/usr/bin/env bash
source /etc/profile
a=0
while [ $a -lt 10 ]
do
echo $a >> /var/log//t.txt
a=`expr $a + 1`
done
</code></pre>
<p>For some reason, the service doesn't come up and systemctl is showing the below output. </p>
<pre><code>root@TARGET:~ >systemctl status -l hello
* hello.service - NandaGopal
Loaded: loaded (/usr/lib/systemd/system/hello.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: https://google.com
</code></pre>
<p>Been trying to figure out what went wrong for the last 2 days.
Could anyone please help me here?</p>
<p>Regards,
nandanator</p>
| 0debug |
How to do math pow with decimals : <pre><code>double variable1= 1.125;
double variable2= 1/7;
Math.Pow(variable1,variable2);
</code></pre>
<p>the problem is when using doubles variable2 returns 0 so the Math.Pow result is not acurate, i should use decimals but it is not suported with Math.Pow , what should i do ?</p>
| 0debug |
Google/Facebook Sign In in MVVM : <p>I'm using MVVM structure with Data Binding in my project. Things get weird when it comes to GG/FB Sign In, because they need <code>Context</code></p>
<pre><code>googleApiClient = new GoogleApiClient.Builder(context)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
startActivityForResult(signInIntent, GOOGLE_AUTH);
</code></pre>
<p><code>GoogleApiClient</code> needs <code>Context</code> so I can't pass it to ViewModel, which receives DataBinding events.</p>
<pre><code>class LoginViewModel(
dataManager: DataManager,
schedulerProvider: SchedulerProvider
) : BaseViewModel<LoginNavigator>(dataManager, schedulerProvider) {
fun loginGoogle(){
setIsLoading(true)
//No idea what to write in here
}
}
</code></pre>
<p>Is there any way to use Gg/FB Sign In with MVVM structure ? Or I just have to do the original way (do everything in <code>Activity</code>) ?</p>
| 0debug |
Meaning of Zero Before Number in Java : <p>I have a code like this, but I don't know why result variable have false value after execution the code</p>
<pre><code>int x = 234;
boolean result = (x<0250);
</code></pre>
<p>and also why the following code doesn't work properly?</p>
<pre><code>System.out.println(0250);
</code></pre>
<p>it prints 168 !! why?!</p>
| 0debug |
Form calculate with integer javascript : <p>I want the user to insert a number e.g. 10 and make the calculation var newbalance + balance + 2, but the output of this code would be 102 and not 12. I think my script thinks the var balance is not an integer but a word or something. how can I fix this</p>
<pre><code><form id="form" oninput="checkChange()" onchange="checkChange()">
<div class="container100 t-center" style="font-size:0;">
<div class="container20 t-center">
</div>
<div class="container60 t-center">
<div class="container60 t-center" style="font-size:0;">
<div class="container60 t-center">
Balance
<input name="balance" type="text" style="width:90%;" placeholder='balance'>
<input type="text" id="mytext">
</div>
</div><br><br>
</div>
<div class="container20 t-center">
</div>
</div>
</form><br>
<button id="submit" class="button" onclick="command()">Submit</button><br><br>
<script>
document.getElementById('submit').onclick = command;
var submitButton = document.getElementById('submit');
submitButton.onclick = command;
function command() {
event.preventDefault();
submitButton.style.background = 'rgba(92,184,92,1)';
}
function checkChange(){
submitButton.style.background = 'rgba(90,90,90,1.0)';
}
function command(){
var x = document.getElementById("form");
var balance = x.elements["balance"].value;
var newbalance = balance + 2;
document.getElementById("mytext").value = newbalance;
}
</script>
</code></pre>
| 0debug |
c program to find percnetage : i am a beginner in coding ,i am trying to make a program where i input 'n' number of elements in array and find out what percentage of number are positive,negative and zeros.the output is not what i am expecting it is all 'zeros'.Where i input n=3,so the percentage should be 1,1,1 when i input numbers one positive,one negative and one zero.
#include <math.h>
#include <stdio.h>
int main()
{
int n;
float per1,per2,per3;
scanf("%d",&n);
int arr[n];
for(int i = 0; i < n; i++){
scanf("%d",&arr[i]);
}
int sum1=0;
int sum2=0;
int sum3=0;
for(int i=0;i<=n-1;i++)
{
if(arr[i]<0){
int sum1=sum1+1;
}
if(arr[i]>0){
sum2=sum2+1;
}
else
{
sum3=sum3+1;
}
}
per1=sum1/n;
per2=sum2/n;
per3=sum3/n;
printf("%.6f\n%.6f\n%.6f\n",per1,per2,per3);
return 0;
}
output
`3
1
-2
0
0.000000
0.000000
0.000000`
the last three numbers should be 1,1,1 but it is giving zeros.
| 0debug |
static int mxf_read_primer_pack(MXFContext *mxf)
{
ByteIOContext *pb = mxf->fc->pb;
int item_num = get_be32(pb);
int item_len = get_be32(pb);
if (item_len != 18) {
av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n");
return -1;
}
if (item_num > UINT_MAX / item_len)
return -1;
mxf->local_tags_count = item_num;
mxf->local_tags = av_malloc(item_num*item_len);
if (!mxf->local_tags)
return -1;
get_buffer(pb, mxf->local_tags, item_num*item_len);
return 0;
}
| 1threat |
Bootswatch theme not working correctly : <p>It's my first time working with ASP.NET, I'm trying to use a Bootswatch theme but when I try to use it the navigation bar at the top of the page turns into a weird drop-down menu.</p>
<p>Am I doing something wrong? I just replaced the current bootstrap.css with the new one from Bootswatch.</p>
<p><a href="https://i.stack.imgur.com/jO6jf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jO6jf.png" alt="This is the result"></a></p>
| 0debug |
int ff_parse_packing_format(int *ret, const char *arg, void *log_ctx)
{
char *tail;
int planar = strtol(arg, &tail, 10);
if (*tail) {
planar = (strcmp(arg, "packed") != 0);
} else if (planar != 0 && planar != 1) {
av_log(log_ctx, AV_LOG_ERROR, "Invalid packing format '%s'\n", arg);
return AVERROR(EINVAL);
}
*ret = planar;
return 0;
}
| 1threat |
How to run my python script parallely with another Java application on the same Linux box in Gitlab? : I have a jar file which needs to be continuosly running in the Git linux box but since this is a application which is continuosly running, the python script in the next line is not getting executed. How to run the jar application and then execute the python script simultaneously one after another?
#.gitlab.ci-yml file
1. pwd && ls -l
2. unzip ZAP_2.8.0_Core.zip && ls -l
3. bash scan.sh
4. python3 Report.py
scan.sh file has the code "java -jar app.jar"
Since, this application is continuosly running, 4th line code "python3 Report.py" is not getting executed.
How do I make both these run simulataneously without the .jar application stopping?
| 0debug |
Got NullReferenceException When I use same code but different exception : What is the difference bet ween these two?
ParamLv[] PLArray = { Mebius, Force, Aegis, Magius };
for (int i = 0; i < PLArray.Length; i++)
{
PLArray[i] = new ParamLv(Data, SArray[i]);
}
When I use object "Force" with the top one code, I got NullReferenceException, but it's normal when I use bottom one.
Mebius = new ParamLv(Data, SArray[0]);
Force = new ParamLv(Data, SArray[1]);
Aegis = new ParamLv(Data, SArray[2]);
Magius = new ParamLv(Data, SArray[3]);
| 0debug |
Convert python regex pattern to lua : <p>I have a pattern but I don't know how to convert to Lua pattern
here is my pattern:</p>
<pre><code>(?P<Protocol>https?:\/\/)?(?P<Subdomain>\w*\.)?(?P<Domain>(?:[a-z0-9\-]{1,})\.(?:[^\s\/\.]{2,}))(?P<Path>\/proxy)?(?P<Params>(?:\?|\#)[^\s\/\?\:]*)
</code></pre>
<p>anyone can help me to convert or convert it for me?</p>
| 0debug |
void qmp_migrate_set_parameters(bool has_compress_level,
int64_t compress_level,
bool has_compress_threads,
int64_t compress_threads,
bool has_decompress_threads,
int64_t decompress_threads,
bool has_cpu_throttle_initial,
int64_t cpu_throttle_initial,
bool has_cpu_throttle_increment,
int64_t cpu_throttle_increment,
Error **errp)
{
MigrationState *s = migrate_get_current();
if (has_compress_level && (compress_level < 0 || compress_level > 9)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
"is invalid, it should be in the range of 0 to 9");
return;
}
if (has_compress_threads &&
(compress_threads < 1 || compress_threads > 255)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"compress_threads",
"is invalid, it should be in the range of 1 to 255");
return;
}
if (has_decompress_threads &&
(decompress_threads < 1 || decompress_threads > 255)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"decompress_threads",
"is invalid, it should be in the range of 1 to 255");
return;
}
if (has_cpu_throttle_initial &&
(cpu_throttle_initial < 1 || cpu_throttle_initial > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"cpu_throttle_initial",
"an integer in the range of 1 to 99");
}
if (has_cpu_throttle_increment &&
(cpu_throttle_increment < 1 || cpu_throttle_increment > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"cpu_throttle_increment",
"an integer in the range of 1 to 99");
}
if (has_compress_level) {
s->parameters.compress_level = compress_level;
}
if (has_compress_threads) {
s->parameters.compress_threads = compress_threads;
}
if (has_decompress_threads) {
s->parameters.decompress_threads = decompress_threads;
}
if (has_cpu_throttle_initial) {
s->parameters.cpu_throttle_initial = cpu_throttle_initial;
}
if (has_cpu_throttle_increment) {
s->parameters.cpu_throttle_increment = cpu_throttle_increment;
}
if (has_tls_creds) {
g_free(s->parameters.tls_creds);
s->parameters.tls_creds = g_strdup(tls_creds);
}
if (has_tls_hostname) {
g_free(s->parameters.tls_hostname);
s->parameters.tls_hostname = g_strdup(tls_hostname);
}
} | 1threat |
why text file created is blank? : My code is
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
struct info
{
char product_name[100], Seller_Name[100], DOP[30];
int price;
}data;
void main()
{
ofstream fout("code.txt",ios::out);
fout<< "ofstream fout(\"data.dat\",ios::binary|ios::out);\n" ;
while(1){
cout << "Enter Product Name: ";
gets(data.product_name);
cout<<"Enter Seller Name: ";
gets(data.Seller_Name);
cout<<"Enter Date of Purchase: " ;
gets(data.DOP);
cout<<"Enter Price:" ;
cin>>data.price;
fout<<"strcpy(data.product_name,"<<data.product_name<<");";
fout<<"\nstrcpy(data.Seller_Name,"<<data.Seller_Name<<");";
fout<<"\nstrcpy(data.DOP,"<<data.DOP<<");";
fout<<"\nstrcpy(data.price,"<<data.price<<");";
fout<<"fout.write((char*)&data,sizeof(info));\n";
}}
I am developing a software and am making sample data for it. So I made this application so I just have to copy statements and need not have to write it again. It worked the first time but now it is not working... Thankyou...
| 0debug |
static void decode_mb(MadContext *t, int inter)
{
MpegEncContext *s = &t->s;
int mv_map = 0;
int mv_x, mv_y;
int j;
if (inter) {
int v = decode210(&s->gb);
if (v < 2) {
mv_map = v ? get_bits(&s->gb, 6) : 63;
mv_x = decode_motion(&s->gb);
mv_y = decode_motion(&s->gb);
} else {
mv_map = 0;
}
}
for (j=0; j<6; j++) {
if (mv_map & (1<<j)) {
int add = 2*decode_motion(&s->gb);
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
} else {
s->dsp.clear_block(t->block);
decode_block_intra(t, t->block);
idct_put(t, t->block, s->mb_x, s->mb_y, j);
}
}
}
| 1threat |
Why does this work?(scanf in do_while) :
I can't understand why this does exactly what I want. The part where I used two scanf's in the loop confuses me. I compiled it using devcpp.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int dend, dsor, q, r;
char c;
while(c!='n')
{
printf("enter dividend: ");
scanf("%d", &dend);
printf("enter divisor: ");
scanf("%d", &dsor);
q=dend/dsor;
r=dend%dsor;
printf("quotient is %d\n", q);
printf("remainder is %d\n", r);
scanf("%c", &c);
printf("continue? (y/n)\n");
scanf("%c", &c);
}
system("PAUSE");
return 0;
} | 0debug |
static int ram_load(QEMUFile *f, void *opaque, int version_id)
{
int flags = 0, ret = 0, invalid_flags = 0;
static uint64_t seq_iter;
int len = 0;
bool postcopy_running = postcopy_state_get() >= POSTCOPY_INCOMING_LISTENING;
bool postcopy_advised = postcopy_state_get() >= POSTCOPY_INCOMING_ADVISE;
seq_iter++;
if (version_id != 4) {
ret = -EINVAL;
}
if (!migrate_use_compression()) {
invalid_flags |= RAM_SAVE_FLAG_COMPRESS_PAGE;
}
rcu_read_lock();
if (postcopy_running) {
ret = ram_load_postcopy(f);
}
while (!postcopy_running && !ret && !(flags & RAM_SAVE_FLAG_EOS)) {
ram_addr_t addr, total_ram_bytes;
void *host = NULL;
uint8_t ch;
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
addr &= TARGET_PAGE_MASK;
if (flags & invalid_flags) {
if (flags & invalid_flags & RAM_SAVE_FLAG_COMPRESS_PAGE) {
error_report("Received an unexpected compressed page");
}
ret = -EINVAL;
break;
}
if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE |
RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE)) {
RAMBlock *block = ram_block_from_stream(f, flags);
host = host_from_ram_block_offset(block, addr);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
ramblock_recv_bitmap_set(block, host);
trace_ram_load_loop(block->idstr, (uint64_t)addr, flags, host);
}
switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
case RAM_SAVE_FLAG_MEM_SIZE:
total_ram_bytes = addr;
while (!ret && total_ram_bytes) {
RAMBlock *block;
char id[256];
ram_addr_t length;
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0;
length = qemu_get_be64(f);
block = qemu_ram_block_by_name(id);
if (block) {
if (length != block->used_length) {
Error *local_err = NULL;
ret = qemu_ram_resize(block, length,
&local_err);
if (local_err) {
error_report_err(local_err);
}
}
if (postcopy_advised &&
block->page_size != qemu_host_page_size) {
uint64_t remote_page_size = qemu_get_be64(f);
if (remote_page_size != block->page_size) {
error_report("Mismatched RAM page size %s "
"(local) %zd != %" PRId64,
id, block->page_size,
remote_page_size);
ret = -EINVAL;
}
}
ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG,
block->idstr);
} else {
error_report("Unknown ramblock \"%s\", cannot "
"accept migration", id);
ret = -EINVAL;
}
total_ram_bytes -= length;
}
break;
case RAM_SAVE_FLAG_ZERO:
ch = qemu_get_byte(f);
ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_PAGE:
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_COMPRESS_PAGE:
len = qemu_get_be32(f);
if (len < 0 || len > compressBound(TARGET_PAGE_SIZE)) {
error_report("Invalid compressed data length: %d", len);
ret = -EINVAL;
break;
}
decompress_data_with_multi_threads(f, host, len);
break;
case RAM_SAVE_FLAG_XBZRLE:
if (load_xbzrle(f, addr, host) < 0) {
error_report("Failed to decompress XBZRLE page at "
RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
break;
case RAM_SAVE_FLAG_EOS:
break;
default:
if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL);
} else {
error_report("Unknown combination of migration flags: %#x",
flags);
ret = -EINVAL;
}
}
if (!ret) {
ret = qemu_file_get_error(f);
}
}
wait_for_decompress_done();
rcu_read_unlock();
trace_ram_load_complete(ret, seq_iter);
return ret;
}
| 1threat |
How to check if all the item values of dict in python are same.? : <p>I have a <code>dictionary</code>: keys are strings, values are integers.</p>
<p>For example:</p>
<pre><code>data = {'a':100, 'b':100, 'c': 100}
</code></pre>
<p>I would like to check if all the item values in dict have same value or not? I can easily check which item value is the greatest but how do I check if all the values are same.?</p>
<p>Thanks</p>
| 0debug |
Asp.net MVC Unlimated Category List Table : Hi how to make unlimited categories
like this;
computer
<br />
computer > Lenovo
<br />
computer > Lenovo > p250
<br />
Electronic
<br />
Electronic > Lise
can you help me?
| 0debug |
static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, mkv_track *tracks, int num_tracks)
{
ebml_master cues_element;
int64_t currentpos;
int i, j;
currentpos = avio_tell(pb);
cues_element = start_ebml_master(pb, MATROSKA_ID_CUES, 0);
for (i = 0; i < cues->num_entries; i++) {
ebml_master cuepoint, track_positions;
mkv_cuepoint *entry = &cues->entries[i];
uint64_t pts = entry->pts;
cuepoint = start_ebml_master(pb, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(num_tracks));
put_ebml_uint(pb, MATROSKA_ID_CUETIME, pts);
for (j = 0; j < num_tracks; j++)
tracks[j].has_cue = 0;
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
if (tracks[entry[j].tracknum].has_cue)
continue;
tracks[entry[j].tracknum].has_cue = 1;
track_positions = start_ebml_master(pb, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
put_ebml_uint(pb, MATROSKA_ID_CUETRACK , entry[j].tracknum );
put_ebml_uint(pb, MATROSKA_ID_CUECLUSTERPOSITION, entry[j].cluster_pos);
end_ebml_master(pb, track_positions);
}
i += j - 1;
end_ebml_master(pb, cuepoint);
}
end_ebml_master(pb, cues_element);
return currentpos;
}
| 1threat |
ggplot ribbon cut off at y limits : <p>I want to use geom_ribbon in ggplot2 to draw shaded confidence ranges. But if one of the lines goes outside the set y limits, the ribbon is cut off without extending to the edge of the plot.</p>
<p>Minimal example</p>
<pre><code>x <- 0:100
y1 <- 10+x
y2 <- 50-x
ggplot() + theme_bw() +
scale_x_continuous(name = "x", limits = c(0,100)) +
scale_y_continuous(name = "y", limits = c(-20,100)) +
geom_ribbon(aes(x=x, ymin=y2-20, ymax=y2+20), alpha=0.2, fill="#009292") +
geom_line(aes(x=x , y=y1)) +
geom_line(aes(x=x , y=y2))
</code></pre>
<p><a href="https://i.stack.imgur.com/94iNd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/94iNd.png" alt="enter image description here"></a></p>
<p>What I want is to reproduce the same behaviour as I get with plotting in base R, where the shading extends to the edge</p>
<pre><code>plot(x, y1, type="l", xlim=c(0,100),ylim=c(-20,100))
lines(x,y2)
polygon(c(x,rev(x)), c(y2-20,rev(y2+20)), col="#00929233", border=NA)
</code></pre>
<p><a href="https://i.stack.imgur.com/bmAd4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bmAd4.png" alt="enter image description here"></a></p>
| 0debug |
static bool vhost_section(MemoryRegionSection *section)
{
return section->address_space == get_system_memory()
&& memory_region_is_ram(section->mr);
}
| 1threat |
General android programming guide lines : <p>I have been programming on android for the past few months and have hit a point where I comprehend the basic ideas and principles for Android development. </p>
<p>Currently I think that my code lacks the appropriate structure and clearance that is required in order for your code to be readable. I know this because sometimes even I find it hard to read my code - and I am not talking about the variable or classes names. I am talking about for example when I open a big ( lengthy ) activity and have 5 overriden methods, 5 more and tons of global variables, a couple of inner-classes and so on it gets hard to find stuff in.</p>
<p>Therefore I have been looking for some guide lines for how to do this so that the code looks good and is readable but I haven't been able to. </p>
<p>There are also small problems to which I find hard to find an answer and usually go with what i feel like rather than knowing for sure what is right in the situation. For example what is better - having the activity implement onClickListener and then having a big switch statement, or just creating new listener for every UI element. </p>
<p>I was hoping some of you might know a place where I can find answers for questions like this. If there is not I will start adding the questions here.</p>
<p>Thank you </p>
| 0debug |
static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p = &s->picture;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize;
uint32_t rgb[3];
uint8_t *ptr;
int dsize;
const uint8_t *buf0 = buf;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return -1;
}
if(bytestream_get_byte(&buf) != 'B' ||
bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return -1;
}
fsize = bytestream_get_le32(&buf);
if(buf_size < fsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
buf_size, fsize);
return -1;
}
buf += 2;
buf += 2;
hsize = bytestream_get_le32(&buf);
if(fsize <= hsize){
av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n",
fsize, hsize);
return -1;
}
ihsize = bytestream_get_le32(&buf);
if(ihsize + 14 > hsize){
av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
return -1;
}
switch(ihsize){
case 40:
case 64:
case 108:
case 124:
width = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
break;
case 12:
width = bytestream_get_le16(&buf);
height = bytestream_get_le16(&buf);
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n");
return -1;
}
if(bytestream_get_le16(&buf) != 1){
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
depth = bytestream_get_le16(&buf);
if(ihsize == 40)
comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
if(comp == BMP_BITFIELDS){
buf += 20;
rgb[0] = bytestream_get_le32(&buf);
rgb[1] = bytestream_get_le32(&buf);
rgb[2] = bytestream_get_le32(&buf);
}
avctx->width = width;
avctx->height = height > 0? height: -height;
avctx->pix_fmt = PIX_FMT_NONE;
switch(depth){
case 32:
if(comp == BMP_BITFIELDS){
rgb[0] = (rgb[0] >> 15) & 3;
rgb[1] = (rgb[1] >> 15) & 3;
rgb[2] = (rgb[2] >> 15) & 3;
if(rgb[0] + rgb[1] + rgb[2] != 3 ||
rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
break;
}
} else {
rgb[0] = 2;
rgb[1] = 1;
rgb[2] = 0;
}
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 24:
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 16:
if(comp == BMP_RGB)
avctx->pix_fmt = PIX_FMT_RGB555;
if(comp == BMP_BITFIELDS)
avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565 : PIX_FMT_RGB555;
break;
case 8:
if(hsize - ihsize - 14 > 0)
avctx->pix_fmt = PIX_FMT_PAL8;
else
avctx->pix_fmt = PIX_FMT_GRAY8;
break;
case 4:
if(hsize - ihsize - 14 > 0){
avctx->pix_fmt = PIX_FMT_PAL8;
}else{
av_log(avctx, AV_LOG_ERROR, "Unknown palette for 16-colour BMP\n");
return -1;
}
break;
case 1:
avctx->pix_fmt = PIX_FMT_MONOBLACK;
break;
default:
av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
return -1;
}
if(avctx->pix_fmt == PIX_FMT_NONE){
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
buf = buf0 + hsize;
dsize = buf_size - hsize;
n = ((avctx->width * depth) / 8 + 3) & ~3;
if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return -1;
}
if(comp == BMP_RLE4 || comp == BMP_RLE8)
memset(p->data[0], 0, avctx->height * p->linesize[0]);
if(depth == 4 || depth == 8)
memset(p->data[1], 0, 1024);
if(height > 0){
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
linesize = -p->linesize[0];
} else {
ptr = p->data[0];
linesize = p->linesize[0];
}
if(avctx->pix_fmt == PIX_FMT_PAL8){
buf = buf0 + 14 + ihsize;
if((hsize-ihsize-14)>>depth < 4){
for(i = 0; i < (1 << depth); i++)
((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf);
}else{
for(i = 0; i < (1 << depth); i++)
((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf);
}
buf = buf0 + hsize;
}
if(comp == BMP_RLE4 || comp == BMP_RLE8){
ff_msrle_decode(avctx, p, depth, buf, dsize);
}else{
switch(depth){
case 1:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, n);
buf += n;
ptr += linesize;
}
break;
case 4:
for(i = 0; i < avctx->height; i++){
int j;
for(j = 0; j < n; j++){
ptr[j*2+0] = (buf[j] >> 4) & 0xF;
ptr[j*2+1] = buf[j] & 0xF;
}
buf += n;
ptr += linesize;
}
break;
case 8:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, avctx->width);
buf += n;
ptr += linesize;
}
break;
case 24:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, avctx->width*(depth>>3));
buf += n;
ptr += linesize;
}
break;
case 16:
for(i = 0; i < avctx->height; i++){
const uint16_t *src = (const uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for(j = 0; j < avctx->width; j++)
*dst++ = le2me_16(*src++);
buf += n;
ptr += linesize;
}
break;
case 32:
for(i = 0; i < avctx->height; i++){
const uint8_t *src = buf;
uint8_t *dst = ptr;
for(j = 0; j < avctx->width; j++){
dst[0] = src[rgb[2]];
dst[1] = src[rgb[1]];
dst[2] = src[rgb[0]];
dst += 3;
src += 4;
}
buf += n;
ptr += linesize;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return -1;
}
}
*picture = s->picture;
*data_size = sizeof(AVPicture);
return buf_size;
}
| 1threat |
Java call performance vs search performance : <p>Currently my program is filled with many ugly references that often make field or method access look like this: <code>weakReference1.get().weakReference2.get().field1.getSomeCustomObject().field2</code>. I want to move to shorter and faster strong references like <code>field1.field2</code>. But my program design is such that I will also have to go for an <code>ArrayList</code> element-by-element search (in a for-loop) instead of accessing a <code>WeakHashMap</code> by <code>get()</code> method.</p>
<p>Thus, I'd like to understand, can moving to simpler references compensate for rejecting <code>HashMap</code> performance wise. Herewith I presume that <code>WeakHashMap.get()</code> is much faster than a loop-search of <code>ArrayList</code>.
Can someone, please, give me a rough estimate? Or maybe there's even an appropriate comparison table like <a href="http://www.asjava.com/core-java/time-consuming-operations-statistics-in-java/" rel="nofollow noreferrer">this one</a>. I'd appreciate that. </p>
<p>Thank you.</p>
| 0debug |
i set tabs but it dint navigate other tabs in angular : this is my code
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#sectionA">Section A</a></li>
<li><a data-toggle="tab" href="#sectionB">Section B</a></li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#dropdown1">Dropdown 1</a></li>
<li><a data-toggle="tab" href="#dropdown2">Dropdown 2</a></li>
</ul>
</li>
</ul>
<div class="tab-content">
<div id="sectionA" class="tab-pane fade in active">
<p>Section A content…</p>
</div>
<div id="sectionB" class="tab-pane fade">
<p>Section B content…</p>
</div>
<div id="dropdown1" class="tab-pane fade">
<p>Dropdown 1 content…</p>
</div>
<div id="dropdown2" class="tab-pane fade">
<p>Dropdown 2 content…</p>
</div>
</div>
| 0debug |
c++ // wrong output ... what is going on? : <p>please can somebody explain this to me</p>
<pre><code>#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int sum = 0;
for(int j = 0; j < 3; j++) {
sum += 24 * pow(10, 3 - j - 1);
}
cout << sum << endl;
return 0;
}
</code></pre>
<p>This is my little program and it is printing out wrong answer (2663 instead of 2664), but when I write <strong>1</strong> * pow(...) instead of 24 everything is good. I am so confuse</p>
| 0debug |
Where is the certificates folder for Docker Beta for Mac : <p>I can't find any certificate files created by <code>Docker Beta for Mac</code>. I need it for my IDE connection to Docker.</p>
| 0debug |
How to set ion-select component with 100% width in IONIC 2 : <p>I would like to set my ion-select with 100% of width.</p>
<p>I have tried with css class like this:</p>
<pre><code>.mySelect { width: 100% !important; }
</code></pre>
<p>But it is not working.</p>
| 0debug |
Optimizing function in python : <p>The function take 4 input as x,y,w,z and I want to optimize the function with constraint as x + y + w + z = 1 and all 4 should be less than 1. How should I approach this task?</p>
| 0debug |
Whats wrong with my code for checking if a site is online or not in android app? : I had been working on a app for my college project. It that application i just want to check if a website is available(online) or not. If it is available then open it in webview and if it isn't open a pre specified website.
After some research I landed up till the following code but it does not seem to work. App always opens bing.com (i.e value of flag does not get updated after running pingHost)
public class MainActivity extends Activity {
WebView web1;
String Address;
int flag=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Timer repeatTask = new Timer();
repeatTask.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
pingHost("http://www.google.com", 80, 5000);
if (flag==1) {
web1 = (WebView) findViewById(R.id.webView1);
Address = "https://learn2lead.home.blog";
WebSettings webSetting = web1.getSettings();
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptEnabled(true);
web1.setWebViewClient(new WebViewClient());
web1.loadUrl(Address);
} else if (flag==0){
web1 = (WebView) findViewById(R.id.webView1);
Address = "http://bing.com";
WebSettings webSetting = web1.getSettings();
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptEnabled(true);
web1.setWebViewClient(new WebViewClient());
web1.loadUrl(Address);
}
}
});
}
}, 0, 10000);
public void pingHost(final String host, final int port, final int timeout) {
new Thread(new Runnable() {
@Override
public void run() {
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(host, port), timeout);
flag = 1;
} catch (IOException e) {
flag = 0;
}
}
}).start();
}
}
PLEASE HELP ME OUT ASAP... I AM SO CLOSE TO DEADLINE FOR SUBMISSION OF PROJECT!!!! | 0debug |
How do I clear the credentials in aws configure? : <p>I have deleted the credentials in <code>sudo nano ~/.aws/config</code> but the credentials are still in <code>aws configure</code>. Is there a way to reset <code>aws configure</code> with clear state?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.