instruction stringlengths 71 95.1k |
|---|
Here's a piece of working code wrote in C to calculate the median without putting all values in an array and sorting them. It reads values from a file.
#include <stdio.h>
#include <stdlib.h>
double find_min(FILE *, double, double);
double find_max(FILE *, double, double);
int main(int argc, char *argv[]) {
int C... |
Each ticket for the Pick-10 lotto has 10 unique numbers ranging from 1 to 99. Suppose you buy a lot of tickets and like to have them cover all numbers from 1 to 99. Write a program that reads the ticket numbers from a file and checks whether all numbers are covered. Assume the last number in the file is 0. Suppose the ... |
Background
A class provides an API to determine the index where two string lists diverge.
import java.util.LinkedList;
import static java.lang.System.out;
/**
* Provides the ability to determine the index whereat two lists begin
* to differ in content. Both this list and the list to comapre against
* must not cont... |
Knowing who's using what, and where, I've implemented a "Rename" refactoring for Rubberduck.
It works great - it needs further extensive testing, but the preliminary tests are very, very exciting.
There are a few things I'm not sure I like though:
The entire logic is implemented in the Rubberduck.UI namespace. The "E... |
I wrote a simple summation program in MARS to practice using loops and jump instructions. I feel like this is pretty lightweight and wanted some feedback on possible improvements:
Lowering instruction count
Organizational changes
Am I correct in assuming this is a "do-while" loop?
# Description: Summation program imp... |
I am wanting to encrypt a password and decrypt a password using PHP. Is this a safe method?
$pass = "password"
//encrypt password
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
$salt = sprintf("$2a$%02d$", 10) . $salt;
$hash = crypt($pass, $salt);
//decryption in second program
if(... |
I've been steadily improving a show many move one carousel sample that I found a few weeks ago. I want to post my improvements for others to use but don't want to spread bad code. I'm not an expert in JavaScript but I always like to produce clean code.
Working demo
(function(){
$('.carousel-showmanymoveone .item').ea... |
A little over a year ago, I asked this question. Since then, I've implemented the larger bit variations and am looking for any and all feedback - performance is obviously key when talking about FNV-1a, but having maintainable code and being correct and decently unit-testable are also paramount.
GitHub
Base class Fnv1aB... |
Is it good to empty an array on focusout?
var arr = [];
$("#automobil").focus(function() {
$.getJSON("auto.json", function(data) {
$.each(data, function(key, value) {
if ($.inArray(value.name, arr) === -1) {
arr.push(value.name)
}
})
});
}).autocomplete({
... |
I am trying to simply measure my code execution time.
public class PerfMeasureUtil {
private static final Logger LOG = Logger.getLogger(PerfMeasureUtil.class.getName());
private long startTime;
private long duration;
private static final EnvironmentProperties env = new EnvironmentProperties();
/**... |
I tried to develop a new way to check if a number is divisible by 9. I have written my code and it is working fine. I'm not allowed to use *,/ and %.
int isDivby9(int x)
{
int status = 0;
int divby8 = 0;
int orgx = x;
if(x>=9)
{
divby8 = x >> 3;
int olddivby8 = ... |
I'm running a jQuery function to equalize heights. I want to equalize the heights of several pairs of elements, and can't think of a way to do so without repeating the whole function.
How can I combine the separate functions below into one function that equalizes the heights of each pair of <div>s without forcing all t... |
When running unit tests in JavaScript it is often useful to gain access to private members. Previously I would add an extra snippet of code inside the class definition (or whatever one calls this in a prototype-based language) to open up the object. Something like this was usually sufficient:
this.internal = function(n... |
I want a generic super-class that I can easily subclass - and if desired add slots to my class - without having to worry about any pickle issues (with the lowest protocol). Is this in general a good idea? And if so, is this class a good implementation?
class HasSlots(object):
"""Top-class that allows mixing of clas... |
I have the following code which I would like to simplify in Haskell, although I'm not sure how. I recall that I can use monads to simplify a case chain when the result of the case leads onto a next bit of code but in my example, I return from the function when I get a value, and continue to the next bit of code if I do... |
I have collected a large amount of data about the train network in my country. Now, I am writing some code that calculates the average amount of delay on the entire train network, for each day, in a given period of time. Important to note: every train has a unique train-number. Each train-number only occurs once each d... |
This is my version of a linked list in C. The function mergeSort requires a reference to the first and to the last nodes, as well as the indices of the first and the last node and a comparator.
You need to compile this source code using C99 standard in order to get it working.
#include <stdio.h>
#include <stdlib.h>
ty... |
Have I followed best practices for PHP development, or can this class be improved?
GitHub
<?php namespace azi;
/**
* Class Validator
*
* @package azi
* @author Azi Baloch <http://www.azibaloch.com>
* @version 1.0
* @license The MIT License (MIT)
*
*/
class Validator {
/**
* RegExp patterns
*
... |
I'm using multiple instances of an object creating a form:
{...
BPFormInputTextFieldCell *nameCell = [[inputTextFieldClass alloc] init];
nameCell.backgroundColor = cellBgnd;
nameCell.textField.placeholder = @"business_name";
nameCell.mandatory = YES;
nameCell.textField.delegate = self;
nameCell.cust... |
I am working through the CodingBat exercises for Java. I just completed this one, an exercise that requests the comparison of substrings of two strings:
Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa",... |
I have the following list to sort:
A 0.53
B 0.56
C 0.56
D 0.98
E 0.33
Please note that my list may contains thousands of such type of records. I am sorting my list and put the sorted list into an array as:
String str="";
for(String s: mylist){
str+=s+",";
}
String[] sArr = str.spl... |
I solved the CodingBat task:
Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz"
yields 3, since the "xx", "aa", and "az" substrings appear in the same
place in both strings.
stringMatch("xxcaazz", "xxbaaz") → 3
stringMatch("abc", "ab... |
I have bunch of similar methods in different classes to average student grades.
In the Student class:
public double getAverageGrade() throws NoGradesForStudentException {
double sum = 0;
int totalGrades = 0;
ArrayList<Subject> studentSubjects = getStudentSubjects();
for(Subject subject : studentSubjects... |
I decided to make a Ruby app to search for songs, which uses the tinysong API. Things got really cryptic and weird in the view. I managed to get dynamic tables that adjust to data length, but I feel like there must be a much better way to accomplish this output.
require "rubygems"
require 'json'
require "httparty"
def... |
I am processing around 3 billion records using this piece of code. It's pretty slow; it would be really helpful if you could suggest better ways to do this.
'''
Created on 27-Mar-2015
@author: siddarth
'''
import rake
import multiprocessing as mp
import time
import os
import csv
filename = 'Large_Input_File.csv'
out... |
I am currently developing a password generator and just finished my first version. I know there is a lot to do but before I proceed with the next version I would like to have feedback on my current source code.
GitHub
The embedded source code does not contain comments to reduce characters.
Main.cpp
void main()
{
Co... |
The problem is adding two lists as numbers L1 = [1,9,9] and L2 = [0,9,9]:
?- sum([1,9,9],[0,9,9], Lo).
Lo = [2,9,8]
But I also wanted to add this:
?- sum([8,1,9],[1,8,2],Lo).
Lo = [1, 0, 0, 1].
I used the backtracking method I've learned:
link([],L,L).
link([Head|Tale],L2,L3):- link(Tale,L2,L), L3=[Head|L].
inve(... |
I am trying to create a simple NodeJS program that monitors few provided servers or machines and provides output in JSON.
// @file name : watch.js
// author : Abhinav Gauniyal
// requires
var os = require('os');
var http = require('http');
var net = require('net');
var diskspace = require('diskspace');
var s = net... |
Problem:I need to write an algorithm that will return length of longest possible palindrome from a given string.
So if the input is aabbbccdfg
Program output should be 7. //-->[cabbbac]
Can someone point it out if there are any problems with below code?
public static void GetLongestPalindromeLength()
{
var ... |
I am creating a game called Othello, the objective of the game is to close in your opponent's stones either horizontally, vertically or diagonally. All the stones that get closed in are then turned to your color. Win the game by having the most stones of your color.
Small example:
b = black
w = white
0 = empty space
... |
The LiveDate object displays the live current date and has a sendAjaxRequest() function dependency to send the AJAX requests.
I'd like to have a full review of any aspects of my code:
OOP
Readability
Performance
Usability
JS conventions
Error handling
Any other suggestions for improvement are always welcome!
sendAjax... |
In order to learn both scala and functional programming, I've been rewriting the projects from my introductory CS class in scala. One of the projects was a plinko game, where the user picks a slot to drop a token into and then the path that the token took and the money won from the end slot is printed to the console. T... |
I had been trying to find a suitable solution to implement localization in my Phonegap/Cordova application. My search proved that any localization through seperate .xml or .json files was a nightmare (mostly due to cross-access-origin).
Because of this, I decided to create a (very) simple, lightweight localization solu... |
I am hoping a Meteor guru can please review my code below and verify if I am properly using return false and event.preventDefault(), especially in the context of form submission.
The reason being, the Meteor docs use this approach:
// Prevent default form submit
return false;
while other tutorials use this approach:
e... |
I'm doing K&R C Exercises. I could use a code review to see how I can improve my logic. The excercise is:
Write a program that prints its input one word per line with getchar.
My basic idea is we need to know whether or not we're in a word. We use the IN status. Every time we hit a blank space, tab, or newline, the... |
As I'm new to HTML + CSS + JS I've been building a calendar (which I think anyone can use as a basis) but would like to get your suggestions on how I could improve my code specifically from the perspectives of:
Adherence to best practices in HTML + CSS + JS.
Usability.
Browser compatibility.
Note: The console logging... |
The following code creates a recursive backup of a directory in the form of interlinked HTML files, structured in the same form as the input directory.
It does not take the backup of the contents of a directory, just stores the names and sizes of all the files and folders contained in the directory.
(It can be though... |
I'm learning C++ so I thought I'd make game of life for practice and explore pointers, 1.5D arrays and stuff like that.
I have "finished" my implementation, but I have trouble with memory access. It seems like I'm stepping over the bounds somewhere and I simply can't figure out where. Everything looks fine to me.
Probl... |
The NICTA Haskell Course presents the following function to implement on List:
data List t =
Nil
| t :. List t
deriving (Eq, Ord)
And the function:
filtering :: Applicative f => (a -> f Bool) -> List a -> f (List a)
filtering _ Nil = pure Nil
filtering f (x :. xs) = (++) <$> ((\y -> case y of True -> x :. ... |
Task (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.
Also, the condition is is not to use pointers and structs etc because they will be considered in next chapters.
I'm new in C, and want to know what in my solution is bad idea and what ca... |
I needed a way to find the number of arguments a function or operation in Rebol accepts (the functions arity). I could not find any direct support for this in the language, so I made my own arity function:
arity: func [
"Returns the arity of a function, disregarding refinements."
:f [function! op! native! actio... |
Just recently I've wanted to update the PHP scripts I use to fetch information from a database for an iOS application. I've got around to it today, and I had a few questions that'd I like a second opinion on before I use these scripts.
Will this method of operation work? As in, since the query and connection are in tw... |
I have made an attempt to write the mergesort routine on a LinkedList in Java. It will be great if somebody can review my implementation and point out the issues with it.
public class LinkedListSort{
static class Node<T extends Comparable<T>>{
private T value;
private Node<T> next;
public N... |
Are there any ways I can make my program more efficient? My program runs, but are there any things that are unneeded that I included?
The local Driver's License Office has asked you to write a program
that grades the written portion of the license exam. The exam has 20
multiple choice questions. Here are the corr... |
I have a 2D lattice with U × U number of grids. My goal is to create an array – of shape U^2 × U^2 – where each entry denotes the least-distance between each grid and any other grid.
Currently, for U=60, my Python script takes ~5 minutes to complete. As a novice programmer, I suspect there must be a more efficient ap... |
Say I am given a csv file that I want to import into an sqlite3 database. The first two columns in the csv file contain unique, important information while the rest of the columns are really a list of things. So the csv file with the header row could look like:
cucumber.csv
'important1', 'important2', 'listItem_1', ... |
I have the following Sieve of Eratosthenes algorithm:
public static ArrayList<Integer> sieveOfEra(int limit) {
int crosslimit = (int) Math.sqrt(limit);
boolean[] sieve = new boolean[limit+1];
ArrayList<Integer> primes = new ArrayList<Integer>(Arrays.asList(2));
for (int n = 4; n <= limit; n += 2) { /... |
I am working on a library in which I need to execute my URL using AsyncRestTemplate and after that I will get a json response back if it is successful. I am also making DataResponse object whether the response is successful or not which I will return back to the caller of my library.
If the response is not successful t... |
I wrote a script for my Raspberry Pi that keeps checking my external IP. If it changes, the Raspberry Pi will send me the new IP via email.
Any suggestions for improvements?
#!/usr/bin/python3
import os, time
def getIP():
os.system('dig +short myip.opendns.com @resolver1.opendns.com > raspip.txt')
wit... |
There are three functions involved. The first Init is run before the content is parsed. The second is parseContent where the content is generated. The third is displayPage that renders the page and HTML for the user.
They are within an OOP class that uses template files which have #KEYWORDS# that are dynamically replac... |
I want to convert db columns such as is_deleted or product_code which consist of xx_xx to java-style names: isDeleted or productCode. I wonder if there is a way to improve my following code, using regex or such things.
def getJavaName(column):
words = column.s... |
Any suggestions?
#include<iostream>
using namespace std;
class node
{
friend class linked;
private:
int data;
public:
node *link;
node()
{
data=0;
link=NULL;
... |
I'm currently learning C# so I can make real games with Unity. This is the first C# program I've built in Unity. Essentially what is does is control the thrust, and rotation of a GameObject shaped like a rocket. It may not necessarily be "real physics" but for my first program, it's good enough.
using UnityEngine;
usin... |
I would like to unit test my web requests, so on top of my head I came up with the solution below.
Since it seems to be working fine, I'm posting it on this site. Though it doesn't feel very dynamic, I would like your input. For example, this solution can't simulate response headers, which I'm also interested in mockin... |
I'm trying to understand memoization using Scala. I took the Fibonacci sequence as an example because of the high cost of recursively computing numbers in the sequence without memoization.
class memoize private (val f: Int => Int) {
import scala.collection.mutable
val cache = new mutable.HashMap[Int, Int]()
def m... |
I'm working on a port of some existing inline x86_64 assembly code to AArch64 compatible assembly and would appreciate the feedback. I'll post below the original x86 and my ported AArch64 code.
The purpose of the original x86 code is to increment a long/double value and handle overflow. My main concern is that due to d... |
I need to implement some function and I would like to report about a fail made inside a function. If function doesn't fail I need to get a some result (for example, std::string). I see two ways to implement function:
// 1. report with exception
std::string foo() {
std::string ret;
... // solving str
if (is_fail(... |
I am trying to code for both recursive and iterative approach to a problem.
Below is a recursive code to print the nodes of binarytree column wise. Basically I have count of root as 0 and if I move left I decrement count by 1 and if I move right I increment the count by 1:
public void printcolumnOrder_recursive(Tree cu... |
I'm working on a C++ custom memory allocator, that would be kind of a replacement for the C flexible array syntax, you know, the stuff like that:
struct C_Arena
{
struct Header header;
size_t size;
size_t used;
char* data[];
};
...
struct C_Arena *arena = malloc(1000);
arena->size = 1000 - sizeof(struct C_flexi... |
I have a system in which user id is "sharded" across all the machines which means each machine is responsible for certain user id data. I am working on a library which will take DataKey builder object which contains user id, timeout, and some other stuff. I will be using this user id to figure out which machines have t... |
I have been trying to create an event queue system using SDL. I've been trying to use this for Pong. The game is not even finished yet, but I stopped work to examine how my event system is organized.
Event_Queue - This is the heart of the system. All events go through here and all listeners come through here.
Event - ... |
Challenge:
Swap positions in a list
Specifications:
Your program should accept as its first argument a path to a filename.
The file contains several test cases, one on each line.
Each test case is a list of numbers, supplemented with positions to be swapped.
List and positions are separated by a colon.
Posi... |
I have made this small text-based casino game in C++. How could I improve it? Be as picky as you'd like.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
// General functions
void bankrupt();
// Roulette functions
void roulette01();
void roulette02();
void rouletteWin();
void rouletteLoss... |
I've just finished with my python implementation of Conway's Game of Life. Can I get some opinions on it?
import pygame
import sys
import time
import random
rules = '''
1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbour... |
I need to know how many times a substring occurs in a given string. I figured that I might as well create an extension method:
public static int Occurences(this string str, string val)
{
string copy = str;
int instancesOf = 0;
int indexOfVal;
while ((indexOfVal = copy.IndexOf(val)) != -1)
{
... |
Debug experience can be much improved in the Lazarus development interface. Please, if you use this free development environment and have the same felling, do not consider this affirmation simply as a "drawback". I would rather consider it as a challenge for improved documentation and contributing back to the community... |
I have been learning HTML/JavaScript and CSS. I have gone through some of the online tutorials, PDFs and books as well. Though, now I am familiar with syntactical stuff, I wasn't sure how I should design or structure code, so I started with a small ToDo application. I didn't want to use any frameworks. As I am still le... |
This is my first ever project and first GUI. I have finished it (with help from Stack Overflow) and it works but is very slow. Can anyone suggest improvements for speed, best practices or usability.?
It currently takes 16 seconds from pressing run in Eclipse to something appearing on my screen. You will need RXTX lib ... |
In column A, I have many strings ~ 32000 cells each containing unique string values. I then have columns C to as many as 30/40 columns which all contain approximately 400 rows of text.
Check column (j) for any text not present in column A
If true then add new string to column A
Run comparison of Column A against colu... |
I finished coding Conway's Game of Life in JavaScript and HTML table.
logic cells in a table will be assigned with unique id's and based on the id operations(based 4 rules) take place.
You can find the working code at Codepen or i have put the code below.
The thing is it works well with any number of rows and 9 columns... |
I have done #1 of Project Euler's in Ruby. Using two different approaches. One uses set, another uses reduce.
require 'set'
start = Time.now
s1 = Set.new (1..1000/3.floor).map { |x| 3 * x }
s2 = Set.new (1..1000/5.floor).map { |x| 5 * x }
sum = s1.merge(s2).to_a.inject(:+)
duration = Time.now - start
puts "Sum: #... |
I am making a simple function that retrieves a 3x3 cells out of NxM grid and determines the direction of cells base on their previous and next neighbor. It will return either any of the following
HORIZONTAL
VERTICAL
TOP_LEFT
TOP_RIGHT
BOTTOM_LEFT
BOTTOM_RIGHT
or INDETERMINATE
Suppose I have this data:
0 1 0
0 1 0
0 1... |
I tried to write a script which takes a list of URLs, checks if their FreeDNS record points to the current IP, and updates the record if not.
Intended use is that the script will be run periodically to keep FreeDNS always pointing to the dynamic IP.
Also, a log is kept so the user may later inspect what the script did.... |
Below is a function that adds a new user to the database using their email and password. I am using Flask and SQLAlchemy.
@app.route('/users', methods = ['POST'])
@require_appkey
def registerUser():
errorsList = []
userInfo = request.get_json()
# Get "email" and "password"
email = userInfo.get('email')... |
I am trying to understand good design patterns in Python and I cannot think of a way to break this huge function into smaller parts without making the code cluttered, overly complex or plain ugly.
I didn't want to clutter my question by posting the whole file. This function itself is already very large, but the class h... |
The code below takes a String and encrypts it using AES/CBC/PKCS5PADDING as transformation. I am learning as I go and I have a few questions about my code.
Is SecureRandom ok for generating my KEY and my IV?
What's up with all these exceptions?
Is my code creating any vulnerabilities in the encryption process? (mista... |
I've got a function that's executed in a game loop. There are a couple of checks that are really only necessary during the first pass of the game loop. How can I remove these? There is more code like this, but this is the shortest example.
public void Update(Frame rawBodyData)
{
//Catch the first pass, where RawBod... |
I'm going through the book Introduction to Algorithms. I made a comparison between merge-sort for an array of integers versus a vector.
Could I have structured this program better? Why is the vector version so much slower? Sorting 2 million integers with a vector type took almost 2 seconds but sorting the same list ... |
I'm currently learning C# as first programming language and I've made a simple program to exercise the basic concepts. It's nothing fancy especially compared to advanced stuff you normally talk about, but I would like to know if I've made some common mistakes or I missed some good practices.
Basically I created a log-i... |
I've got a project I've been working on that connect to a file server and writes some data to a text file. In order to do this I added a textbox for the user to type their username and a passwordbox well for the password. In my models I have an interface called IPassword that looks like the following:
public interface ... |
In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one HelpersContainer that contains all helpers. Any helpers must see any other helpers.
//1 network peer = 1 GamePeer object
class GamePeer
{
HelpersContainer helpersContainer = new HelpersContainer(dbWorker... |
I've written my first Python program longer than 15 rows and, of course, it looks terrible.
I'd be very glad to receive comments and suggestion about how to implement a similar tool correctly.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This script imports the csv data into a mysql database
import csv
import MySQLdb
... |
So I was doing something which creates an airplane with an actual airline code, number, airplane type and so on.
The airline code and airplane type are stored in a txt file so I can add more later to my leisure... but the code I came up with to get a random line is extremely messy. Is there a better way? I searched all... |
Here is my implementation of double linked list. Is it possible to reduce the code and improve it?
Some methods here:
head (returns head of the list) tail (returns tail of the list);
append (param: new data; add new item to the end of the list);
deleteAt (param: index; deletes item by index; error handling)
a... |
The program takes census data from a text file in the format age, gender, marital status, district. It then gives a list of residents by district (there are 22) and by 5 age groups. Any suggestions for improvement?
The only topics we have covered so far in class are methods, decisions, looping, and arrays.
static void... |
I've written my first implementation of quicksort in Java 8. Please let me know of any improvements that I can make (e.g. whether I'm creating any Lists unnecessarily).
Also, when I try to add elements directly to the leftArray, I get a ConcurrentModificationException. Doesn't subList() create a new List that's separat... |
I have an implementation of a quad tree and abstract collision detection classes. The code works but looks very ugly, but I don't know what I could change to make it better.
The reason I used two interfaces instead of just extending an abstract class is because the classes which will use this are render objects and hav... |
A game I've created to implement everything I've learned and to further build upon. I just recently learned classes so I'm probably using them wrongly.
Every bit of criticism is appreciated, I don't want to create bad habits.
Edit: My game draws up a field / map of symbols and characters which represents the playing fi... |
I have the following but it takes long time to run, it is a simple wherein the user select a file and data from Sheet1 is copied to another workbook.
Sub ImportApp(ByVal filepath_Report As String, file_name1 As String, wsOutput As Worksheet)
Application.ScreenUpdating = False
Set wbReport = Workbooks.Open(file_... |
I'm looking for feedback on this live-filter I wrote in JavaScript. You can test it using the included snippet.
(function() {
var searchField = document.getElementById('filter');
var handler = function() {
var text = searchField.value,
nodes = document.getElementsByClassName('phase'),
regexp = ne... |
I'm really a newbie with code, and I wish to prepare all my statements to avoid SQL injection. I have searched a lot on the internet, but this wrapper/API doesn't look anything like the examples given.
And I'm not yet skilled enough to fully understand how I should rework it to fit mine:)
This is my code
<?php
/**
* p... |
I have created JavaScript code using REST API for getting the username of a SharePoint user from an active directory if you know the ID. Please suggest any improvements.
// get user name from id
function getUserFromId(userid) {
// var userid = _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsolu... |
In my very specific scenario, I need to get an NSDate holding the next time the hour will be 7 (either AM or PM).
On the case that this is the first time to do this, I need to jump extra 12 hours (e.g., if I got Apr 1st 7AM - to jump it to 7PM).
After playing with playgrounds I was able to achieve what I believe solves... |
I have made my first app in Android Studio. I made a compass using a sensor-listener.
I would greatly appreciate if someone could review my code (it is very short), and suggest improvements.
My XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
... |
I asked this question on StackOverflow, got some answers, most notably a link to this one, and basing on that I've implemented this:
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Control.Monad.State
import Control.Monad.IO.Class
-- Module
-------------------------------------... |
I'm using MVC in order to generate a couple of views within my webpage. For a way of logging in, I've decided to use Asp.net's Identity, which I am very happy with.
However, I'm trying to find an efficient/ 'normal' way of testing if the user is logged in, and are looking at info that refers to them.
As a test, I found... |
The code below attempts to extract incomplete weeks from a List<DateTime>.
For example, a list containing all the days in Jan 2015 would result in the 5th to the 25th inclusive.
I know the list going in will contain unique dates, and are in date order. It seems to be working but I can't help but think this could be don... |
Here is the interface of my generic dynamic array;
/* dynamic array interface */
#ifndef DA_HEADER
#define DA_HEADER
#include <stdlib.h> /* size_t */
/* creates a new dynamic array, with each element of "size" bytes */
void *danew(size_t unitsize);
/* returns pointer to element after the last element */
void *daend... |
This is designed for a high performance complex log analyzer. Very simple idea: read a file line-by-line as fast as possible.
I would appreciate any hints what should/could be improved in this code.
GitHub
FastLineReader.h
/* Copyright (c) 2015 Simon Toth kontakt@simontoth.cz
* Lincensed under the MIT license: http://... |
I am very new to Python, and also this is my first time trying to parse XML.
I am interested in information within str elements. I can identify that information using the str@name attribute value.
def get_cg_resources(pref_label, count=10):
r = request_that_has_the_xml
ns = {'ns':"http://www.loc.gov/zing/srw/"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.