instruction stringlengths 71 71.9k |
|---|
After getting the requested controller from the URI request, it checks whether this exists and whether the requested method (default index) exists within that controller, then calls them.
My intention is to have everything running object oriented so I'm trying to remove any procedural/unattached variables that may appe... |
I am using the following code in order to retrieve the index for an object stored in a JavaScript array.
Scripts works fine, but I would like your opinion regarding performance.
Also would like to know also if using [].map() could be more appropriate of [].some().
http://jsbin.com/nasiyiyavi/1/
var data = [{ id: 3 }, ... |
I've implemented generic insertAt function which inserts element into both indexed and ordinary lists. Here are some examples:
-- ordinary list
insertAt 1 5 [1, 2] == [1, 5, 2]
-- indexed list
insertAt 1 5 [(0,1), (1,2)] == [(0,1), (1, 5), (2, 2)]
Here is the code:
{-# LANGUAGE TypeFamilies, FlexibleInstances ... |
We have just started up a new app and we are using React with the Flux architecture. We have done our best to piece together what we think is the best structure for the app and would appreciate any feedback, suggestions etc. The component is essentially a settings page in a much larger system, it basically gets and upd... |
I made this script so that I can scale objects for 3D printing from Maya.
I had fun making it and I'm sure it could be cleaned up or improved. If it can be cleaned up please let me know.
## ((Ax - Bx)**2 + (Ay - By)**2 + (Az - Bz)**2)**0.5
import maya.cmds as mc
def defineParameters():
selPoints = mc.ls(sl = Tru... |
I am burdened with the requirement of interacting with a C based library, which has a bunch of constant sized arrays (e.g. char[17]).
When trying to assign or read those properties from swift, they are represented as a Tuple type of that size..
As far as I know, you can't access tuples with subscripts, and it is not t... |
I have created a custom scatterplot in Qt and am wondering if there is a more efficient way to do it. Here is a sketch of the problem:
The layout of the plotting area consists of a rectangular structure starting at [0,0] in the top left corner and expands by 250 pixels to the bottom right corner [250,250]. So the y-c... |
I put together a function to sort out values that I am getting from a curl request for different 'devices', it works as is, I am only wondering if there is an easier way to to this.
function convert($deviceName, $namesArray, $devicesArray) {
$result = array();
foreach ($devicesArray as $d) {
$result [... |
Introduction:
For a project I'm working on I used a BackGroundWorker to lift some heavy tasks away from the UI thread and report progress. For this I created some sort of modal dialog with a label and progress bar which were updated from the ProgressChanged method of the backgroundworker.
I read a very interesting arti... |
I have written a jquery code, which fixes a navbar header on top of page when a user scrolls down to a certain pixels. But I am not sure whether is this the correct way to do this.
Because this is going to be a majorly used function by all users, it would be better if I can improve it in terms of optimizations and spee... |
I've got a use case for namedtuple that requires some of the fields to be floats. I could require the code that's constructing the namedtuple to supply floats, but I'd like for the namedtuple class to be smart enough to convert strings it gets into floats for me (but only for a specified subset of fields). I have code ... |
The normal boostrap affix doesn't take the items natural offset top position into account, you have to manually pass it in as an attribute. This takes care of that, and accounts for the offset top changing on window resize.
var $attribute = $('[data-smart-affix]');
$attribute.each(function(){
$(this).affix({
offs... |
def user_not_authorized(exception)
message = t('flash.access_denied')
if exception.policy.class.to_s.underscore == 'group_policy' && current_user.students.size != 0
current_user.students.each do |student|
student.memberships.each do |membership|
if membership.group_id == exceptio... |
Here is the function which does exactly what is specified by its name:
sub runCmd_getStdoutStderrAndExitCode(@)
{
my @cmd = @_;
# fork a child
my ($child_pid, $child_stdout, $child_stderr);
eval
{
$child_pid = open3(\*STDIN, # is /dev/null when collectl is a daemon, UPDATE: can pass 'undef' here
... |
I am new to android developement.
Created calculator application.
Want to improve my code quality.
Will be helpfull for any advice to make the code better and more professional
(overall structure, splitting onto logical units, accordance to code conventions, methods and variables names, comments etc).
Here is my code:
... |
I wrote a logging class for several of my applications, but I have noticed that it is fairly in-efficient. Can anyone suggest improvements?
What I am looking for:
Pointers on improving efficiency
Tips for lowering the code-footprint
Suggested functional improvements
Please be as nit-picky as possible, I'd like to mak... |
Just a fun batch file I have made. I wanted an easy way to loop any arbitrary command several times: loopme.bat
@echo off
SETLOCAL
echo LoopMe v1.0
IF "%~1"=="/?" (GOTO HELP)
IF "%~1"=="" (GOTO HELP)
IF "%2"=="" (SET TIMEOUT=1) ELSE (SET TIMEOUT=%2)
SET COMMAND=%~1
SET COUNTER=0
:RUN
SET /A COUNTER=%COUNTER% + 1
CMD ... |
I wrote the below function for doing a variation of bisection search that I came up with. This can be useful when the higher bound is not known. It assumes that as number increases the result of the condition is also increasing.
For example - find the largest classroom size where the probability of two students sharing... |
I am stuck on a piece of code that I have written that uses dcm4che. I have made a whole heap of nested ifs and I want to find a way to convert to a switch-case (problem being I have no way of declaring an int that can distinguish between cases). Is there an alternative to making this code snippet appear less ugly?
imp... |
Given a list of strings, my task is to find the common prefix.
Sample input: ["madam", "mad", "mast"]
Sample output: "ma"
Sample input: ["question", "method"]
Sample output: ""
Below is my solution, I'd be happy for help improving the algorithm (I'm open to totally different approaches) or general code improvement tips... |
I would like to present for review my (much) revised batch templating utility which had it's humble beginnings here in a previous post. As I mentioned there, this program is my entry into python programming. I am trying to grow the simple script from my previous post into a more robust utility.
Questions I am hoping... |
I've written a simple binary heap in C# and I want to know if it has any problems or if I can make it better.
public enum HeapType
{
MinHeap,
MaxHeap
}
public class Heap<T> where T : IComparable<T>
{
List<T> items;
public HeapType MinOrMax { get; private set; }
public T Root
{
get { r... |
I put together a Haskell function for Knuth's word wrap algorithm. A simplified version of the algorithm is described here.
I've already been told that there are certain aspects of my style that are not very agreeable (e.g. lack of comments and type declarations). However, I'd like to get some opinions on where I migh... |
Spent some time implementing a graph as an adjacency list. Looking for suggestions on how to improve this implementation.
#include<vector>
#include<iostream>
class Graph{
public:
//n is the number of vertices in graph
Graph(int n)
{
N=n;
E=0;
//for(int i=0;i < n; ++i)
... |
As an ongoing little side project of mine, I've been working on recording audio in c. You can the code's progression by looking at past versions (V1.0, V2.0).
I've found that my past versions were too limited. They required a certain time frame for which they would record, and then stop. This isn't very practical fo... |
This is my solution for exercise 1-19 of K&R:
Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time.1
It works, but I'm trying to write good programs. I think the fact that I can't use the length of the vector when already got the line in ... |
I am looking for suggestions on how to improve my mergesort. My teacher explained the recursive mergesort and left the bottomUp one as an assignment. I have implemented it but find it too messy. I thought the implementation would be more simple.
How can I make it simpler and quicker?
MergeSort
void mergeSortBottomUp(in... |
I'm very new to Go (this is my first real program), and I was hoping to see if there was anything I was missing about the language or any ways to make it more idiomatic.
calculator.go
package calculator
import (
"../stack"
"unicode"
"strconv"
)
func Calculate(input string) int {
stack := new(stack.Sta... |
My code is complete. It runs properly and produces the correct output. I did calculations by hand to check and then ran the program and it gives me the same result. I just want a second opinion. Are there ways for my code to be more efficient? Are there small details that I need to change? My professor marked me off fo... |
Is the following MS VS solution structure and classes OK w.r.t. easy unit tests with dependency injection? Would your unit tests look similar?
If you call the calculations below over a WPF module, would you skip a test over the WPF since complicated, or would you still conisder testing it over the WPF module ?
Solutio... |
CodeChef - QPOINT
Given a 2D vertex of multiple countries, find which country contains a certain point.
Input format:
"Number of countries"
"Number of vertex" "x1" "y1" "x2" "y2" ...
"Number of vertex" "x1" "y1" "x2" "y2" ...
...
"Number of query"
"x1" "y1"
"x2" "y2"
...
Please give me any advise on code style or de... |
I coded this algorithm in order to have a generic backtracking algorithm. I expect the user to pass a POD for ELEMENT, hopefully as small as possible. Any idea how I could improve this?
#ifndef BACKTRACK_H
#define BACKTRACK_H
#include <array>
#include <vector>
#include <assert.h>
template< class ELEMENT, unsigned MAX... |
I have a set of Excel data which I read and assign to corresponding columns of an Excel table. In our Excel we have provided the user the option to rearrange the Excel column fields at runtime.
int rowIndex =int.Parse(ExcelSettingManager.ItemLine);
int lastItem = numberOfFilledRows();
numberOfFilledRows();
int maxI... |
I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on improving the efficiency of my code or another more efficient way to handle query results other than parsing PDOs?
This will r... |
I wrote a sample app based on the ReactJS tutorial, and I would like some thoughts on how idiomatic this code is. Unfortunately there's no ReactJS integration with Stackoverflow snippets, but I do have a working JSFiddle.
You have a phases box, and inside it we have a list of phases, and a new phase form to add a phase... |
Summary
VB6 doesn't have a great selection of data structures to work with, so again I find myself creating my own. I have a need to dynamically generate a directory structure on the file system. The natural way to represent this is with a Tree, so I created my own.
There are three classes involved here:
TreeNode - Th... |
I wrote a JavaFX program that contains a list of notes, each having a title and a content.
This is the controller code:
public class MainPresenter implements Initializable
{
@FXML
private ListView<Note> listView;
@FXML
private TextField titleField;
@FXML
public TextArea contentField;
@FXML
... |
I have this code that reads in a "scrambles" and a "words" file. It compares both files using their canonical form and prints out the words from the "words" file that match a particular scrambled word. I'm looking for ways to make this quicker.
public class scramble
{
public static void main(String[] args) throws ... |
This is a very simple class to handle files.
It allows to access, create and modify files in the system or 2 fake files (one in memory and other similar to /dev/null or nul).
Windows has a 'feature' that automatically converts all the line endings to the correct one. That is one of the features included.
The fake /dev/... |
The destruction of the objects are handled by the garbage-collector metamethod.
(Does this make sense? This means that an out-of-scope object will stay visible in game until garbage collection.)
The components of the Entity Component System are not pure-data members,
but instead derived classes of a specific base class... |
The code below shows the pattern I use to manage properties in my classes when I have the following requirements:
Some properties are slow to calculate and are rarely used, so I want them to be lazy
Some methods change the value of a property
The properties are defined the first time they are requested and are delete... |
A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash.
#include <unordered_map>
#include <glm/glm.hpp>
#include "gl_func.h"
#include "gl_buffer.h"
#include "shader.h"
#include "log.h"
class Renderer
{
private:
typedef void (*RenderFunctionPointer)()... |
I come from MySQL type of mind frame but have worked with MongoDB and ElasticSearch type of NoSQL.
I'm using a small use case of Cassandra to able to scale a playlist format for users.
In C* Summit 2013 by Axel Liljencrantz, he states how deletions are messy - and that deletion in Cassandra are actually tombstones (hen... |
I have a UITableview with custom cells, every cell has a button called cellButton. When the user taps the button I present an action sheet which has two buttons, buttonOne and buttonTwo. When buttonOne has been tapped I call a method with some values from the actual cell, when buttonTwo I perform a segue and prepareFor... |
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *reverseBetween(ListNode *head, int m, int n)
{
ListNode *pre=NULL, *cur=head, *front=NULL, *rear=NULL,*follo... |
I have been making a jQuery morphing button type thing.
jsFiddle
$(document).ready(function() {
var morphObject = {
button: $('button.morphButton'),
container: $('div.morphContainer'),
overlay: $('div.overlay'),
content: $('h1, p'),
init: function() {
this.butt... |
I have a short bash script that processes gigs and gigs of data. I am looking for any improvements to make it faster. This is my very first bash script so please be gentle. I am really only concerned about the while loop. The rest of it is fine I think. It's the while loop where the real work is done and could use th... |
I have a code that I'm fairly certain does what I want. Bear with me as I explain what I'm doing:
Imagine that there is 10 houses, where there can be one to an infinite number of persons. Each of those persons sends a number of messages, containing their userid and the house number. This can be from 1 to infinite numbe... |
I was getting sicker and sicker of using an ordinary collection to do a tree's work, so I built a tree. A requirement of the tree are that it needs to contain a key to sort the tree by, so I used a Dictionary<int, T> to store the items. Here is the Tree<T>:
public class Tree<T>
{
public Tree<T> AddItem(int key, T... |
I worked on an exercise from codewars, which is a variation of the popular fizzbuzz game. (If the link doesn't work, you may need to reload the page.)
In this variation, I'm supposed to find the sum of all the multiples of 3 and 5 that are less than the passed in number.
My code works, but it's horribly inefficient. I... |
I have a situation where I'm stitching three different unions into a triplet tuple for building a map/dictionary of strongly typed values keyed on a string.
One of the union cases is very large, the second has three options, and the third has only two. Right now I loop through the large with reflection, and have six y... |
I'm looking for feedback on my atoi implementation here in C. Any feedback would great. I made my own atoi for fun and to learn about it.
I'm not trying to replace the standard library version. Reinventing the wheel is fun to me.
#include <limits.h> /* for LONG_MAX, INT_MAX */
#include <stdbool.h>
#include <stdio.h>
#... |
Are there more optimization possible in this code to achieve better performance and minimal memory usage?
#include<stdio.h>
char * strrev(char* str)
{
int length=0;
char* str1=str;
while(*str++)
++length;
str=str1;
char temp;
for ( int i=0; i< length/2; ++i)
{
t... |
A univariate polynomial is a polynomial over a single variable, and in
the following discussion when we say polynomial, we mean a polynomial
in a single variable. You are given two polynomials – the first one,
M1(x), is called the multiplicand, and the second one, M2(x), is
called the multiplier. Your progr... |
First off, I want mention that this code works well. This is more of a request for suggestions...
We're attempting to program a one-page, recursive, token-based admin shell that is safe from intrusion, and replicable for several DB backend manipulation pages via tokening. We wanted to protect it from SQL injection (thu... |
I have a NumPy matrix C and want create a copy of it cPrime, which has some operation of the original matrix to all non-zero values of it. In the code below, for each non-zero element of C, I multiply by 30 and then add 1:
import numpy as np
size = 6
C = np.zeros((size,size), dtype=int)
C[4][0] = 2
C[4][1] = 5
C[4][2... |
mappingService below is actually just Automapper. I have a wrapper around it so that I can inject it.
I want to refactor the following code to be cleaner:
public class DropDownListService : IDropDownListService
{
private readonly IMappingService _mappingService;
private readonly ICompanyRepository _companyRepo... |
Essentially the Collatz Conjecture.
Challenge requirements are here.
And here is my implementation in Java:
/* User: koray@tugay.biz Date: 21/03/15 Time: 19:40 */
public class ThreeNOneForRangeSolver {
public int solveFor(int inputOne, int inputTwo) {
int maximumCycleLength = 0;
do {
... |
First revision: Minimal webserver in C++
Here's my test question for C++ programmer job:
Servers only static content, no cgi
Single process, multithreaded
1000 concurrent request at least
Valid http status codes and headers
No external libraries, just STL, POSIX and glibc
Here's my code:
#include <cstdio>
#include <c... |
This is a "pain", but I wonder if I can get any real speedup with the follow Python script - it is taking well over 10 minutes to calculate the way it is written now. (And that's only when feeding around 1-2 promille of the data).
I have an with shape (roughly): [260, 300, 300]
Now I am doing a cougar=feldermann analy... |
Challenge
The recent question The 3n + 1 algorithm for a range inspired me to investigate a Java-8 dependent streaming mechanism for solving the programming challenge:
For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j (inclusive).
The cycle length of a number i... |
This is my first program that uses more than just boring ol' if/else statements - I made a whole 246 line game that's still a work in progress simply using if/else - and I'm going to email this to my teacher later tonight.
Please suggest more things I can add and report any bugs (although I've found none so far).
# Sta... |
I am starting to experience frame rate issues in my game and I've tracked it down to my updateMobs function. I would like tips and code examples from you guys to improve the given code below, to make it more efficient FPS-wise. Can you also tell me why this speeds up my code and by how much, if possible?
var updateMobs... |
I am new in R and I have to implement simulated annealing for schaffer function and I did it. However I am not sure about the correctness of the code.
simulated_annealing <- function(schaffer, step, s0, niter) {
s_n <- s0
iter_count <- 0
for (k in 1:niter) {
T <- (1 - step)^k
s_new <- rnorm(2, s_n, 1)
... |
I recently started to do some of the exercises in CodeChef and I did the TurboSort challenge here is it's description. It works fine with smaller arrays but can't pass some of the tests due to the fact it's \$O(n^2)\$, so I need a faster way to sort them.
import java.util.Scanner;
public class TurboSort {
public... |
I have some concerns, like the updateValue function. I was trying to follow the functional paradigm, but I wonder if I could use another approach or something.
My parsing function seems overly complicated, particularly the '[' case seems complicated. Any other comments are appreciated too!
namespace Brainfuck
module I... |
I'm trying to design the classes for the Wheel of Fortune game in Java. The below diagram represents the classes and the interaction between them.
.
Below is the partial implementation of it. I appreciate some feedback on my design and approach. I'm mainly interested in classes and their dependencies. In code I refer... |
The simple but generic timeout class to be used watching for network connections, user input, filesystem events, and is intended to have a very simple interface specific to only our use cases (i.e. no satisfy-all attitude).
Intended steps to use:
Construct
Activate
Potentially react to a timeout, deactivates itself
Re... |
I have a list of Options. From that list:
First I want to get only Drink (the where clause).
Then I want to group them by their SortOrder (range of 100).
I can stop there and loop through the items and create checkboxes for each items. But I got a requirement that if the OptionGroupName=Alcohol then I need to create r... |
I have written this Java snippet to generate all permutations of a given array of integers. Can somebody review it and give some pointers as to how to make it more generic? I.e. instead of dealing with only ints, it should be able to handle a collection of any data type.
import java.util.Arrays;
public class PrintPermu... |
I have an application that provides the user the ability to backup the local SQLite database to another location. I then provide the ability to restore the backup database and overwrite the current database with the backup copy. In my restore command, I make a backup of the database file, which seems redundant. I fe... |
I'm preparing for an interview. I tried implementing binary search tree in C++. I used array but it seems to be complicated to restructure the array while deleting nodes. Is linked list a better data structure to implement BST? Also please let me know if the code has bad coding practice like memory leak, bad data struc... |
I'm currently doing an algorithms course and implemented this version of the quicksort algorithm. I would like to know if it is an efficient implementation. I've seen a couple others where there is a partition function that partitions the list is that a superior method to what I did?
def quickSort(aList):
first = [... |
Click the divs to remove them. Remove all div's in the shortest time and minimal clicks (to do). Code needs streamlining.
<!DOCTYPE html>
<html>
<head>
<style>
div {
width:30px;
height:30px;
background-color:blue;
position:fixed;
}
</style>
<script>
function init() {
var i;
count=10;
for (i=0;i<10;i++) with (docu... |
Devise an algorithm that will operate on a number x and a set of n
distinct numbers such that in \$O(n \lg n)\$ time, the algorithm indicates
whether or not there are two numbers in the set that have a product of
x. Explain why your algorithm works.
My algorithm:
Sort the set //\$ O(n \lg n)\$
For every element in t... |
Basic Info
I needed a lock-free ringbuffer with multiple readers (but one writer). However, I did not want the writer to check all readers every time in order to prevent an overrun. Thus, I decided to split the buffer in two halves. If the write pointer is in one half, it is only allowed to advance to the next half if ... |
I have sample graphs like the following (un-directed un-weighted cyclic graphs). My goal is to find the shortest path between a given source and destination.
I have found this implementation on web and have made some modifications only. How can the code be improved? Are there any gotchas that I need to take care of?
fi... |
This is the code I have:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct island{
char *name;
struct island *nextIsland;
} island;
void printIslands(island *i){
printf("%s\n",i->name);
if(i->nextIsland != NULL){
printIslands(i->nextIsland);
}
}
island* fileReader(... |
This is a game of math in Poker. Two people each have a pile of cards. They then each place 2 cards on the table at the same time. Every card is treated as a number. The players need to find a way to calculate 24 from the numbers. For example, you are given 3 5 4 8, and you can get 24 by (3+8-5) * 4, or 8*4-5-3. This c... |
I have written the following service class for my application and at the moment it only contains a single method which is responsible for carrying out the necessary actions to add a new team to the database. More methods will be added later but I want to make sure that I'm on the right track with regards to OOP and it'... |
I am trying to implement A* search on a grid in MATLAB. I am currently using a priority queue class I found here, but it's a bit slow. I tried to write this simple priority queue class in MATLAB:
classdef PQ2 < handle
properties
nElements
indx;
priorityList;
valueList;
end
... |
I have written the following class which is part of a pagination system in Wordpress. The class works as expected and also works as expected when used in the system.
Just as background, the class performs the following task
Takes an array of post ID's and creating links to the posts which ID's is supplied in the arra... |
I've created a function in C to reverse a singly-linked list in place:
typedef struct n {
int key;
struct n* next;
} node;
node* inplaceReverse(node* head, int index) {
if(!head || !head->next) {
/* Indication of last node (or empty list). This will be recursively returned to become the new head po... |
1-20 of K&R Exercise 1-20
Write a program detab that replaces tabs in
the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns.
I think my solution is okay. I used the name getlinea when it also "completes" a line when returning from function get... |
I just did CodeChief's candy splitting task here and my code is working even with a lot of test cases and big numbers, but it uses way too much memory. When I checked my submission, it was 1342M, which is a lot.
import java.util.ArrayList;
import java.util.Scanner;
class Candies {
public static void main(String[] arg... |
Can anyone comment on the efficiency of my code? I am new with Python using NumPy/SciPy and I am trying to program a lattice biological model where a certain (one and only one) species (represented by a nonzero element) occupies a lattice square (represented in the code by a 2D array). This species can reproduce to an ... |
Below is the code that implements sequence abstraction using type abstraction Sequence (in Java):
/**
*
* @author mohet01
*
* @param <T>
*/
public class Sequence<T>{
/**
* Abstract data type constitutes constructor and selector functions
* written below under representation that hold below invaria... |
I've just started iOS development and learning Swift. My code below works, but I'm interested to know in ways I can improve it having no experience in iOS Swift prior to this attempt.
import UIKit
class NewsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var tableView: UITableView!
var t... |
Questions:
Is there a better way other than assigning IDs manually and creating separate lists for each model the way I have? (for this particular scenario).
If so, how? (Still taking the conditions into account)
The conditions are:
Through an external source get a list of unique book names with their
correspondi... |
Sort a stack in ascending order. You may only use one additional stack to hold items.
Any comments on my solution?
Worst case complexities:
Memory complexity: O(n)
Runtime complexity: O(n^2)
Also, I implemented the Stack class as having Object items and then cast these into Integers to be more general. Is this a good ... |
The purpose of this code is to generate the CSR and the Private Key.
The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site where they can input the fields like domain name, company name etc and then the system will generate the CSR (and return it... |
I'm not exactly sure if this is technically an "arena allocator" but it serves a similar purpose: providing a fast way to allocate a lot of objects that can all be freed at once.
#include <type_traits>
#include <utility>
#include <new>
template <std::size_t BlockSizeIn = 1024>
struct BlockProviderNewDelete
{
stati... |
I'd like to use JavaScript to generate HTML.
I've made a JavaScript function object that has two parameters; a string and generic object. The string is used to specify the type of HTML element you want to generate and the generic object is a container for key value pairs specifying the element's attributes -- or a stri... |
The following function works fine. However, deleting 1 mail takes about 4 seconds (from start of operation to the firing of the completion handler).
Currently, using mailcore2, copying mails on the Gmail server.
Are there any significant issues?
func deleteOnServer (indexSet: MCOIndexSet) {
NSLog("will delete ema... |
There is a job interview question, and the source of the question is here.
The solution is pretty simple. We just need to split the input string by + and then by *. Then we compute products in a nested loop and sum up all the products.
public class Main {
// http://www.careercup.com/question?id=4911380140392448
... |
Due to being unable to ask a C programming language expert or advanced user in person, I'm posting this simple question about my C code. Today I was refreshing my C with exercise 5.4 of the C programming Language 2nd Edition by K&R, which is a very simple exercise:
Do you think that my way of handling pointers is 'ver... |
Compile time checking of printf-like format strings
Inspired by this open ticket on boost, this seeks to complete the work there
Given a printf-style format string and associated arguments, a static_assert is performed on whether the format string and arguments are valid.
I'm particularly interested in:
Have I covered... |
I'm trying to transition from JavaScript to PureScript (a Haskell spinoff that transpiles to JavaScript). For starters I coded this:
getAt :: [String] -> Number -> Number -> String
getAt strings x y = case strings !! y of
Nothing -> " "
Just line -> case charAt x line of
Nothing -> " "
Just char... |
I've put together an algorithm for an assignment. I've done my best to try and keep it to a professional and readable standard. I'm posting it here so that I can get some feedback and suggestions on what it's like and whether I could improve the algorithm in some way.
/***** Algorithm
Comments - Name: Shivan... |
I'm using a Python script to run a particular program that occasionally may need to be terminated (by receiving a SIGINT or SIGTERM) in which case a clean up process needs to be invoked (before killing the original process).
To test it I start the program in question and then I send a SIGINT to terminate it.
A signal h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.