instruction stringlengths 71 71.9k |
|---|
I wrote a simple SPI Master implementation to send characters to a LCD screen. Only the output is actually implemented in this so there is no rx register. This only sends a character out when write is asserted. I would appreciate any feedback and wanted to test out stackexchange for HDL.
library IEEE;
use IEEE.std_log... |
I wrote a script to perform svn update on all the SVN repositories inside a folder. It would have been great if the folder containing all these repositories itself was a repository, but it was not setup like that, which is why I opted to write this script.
$timestamp = get-date -f "yyyy-M-d-h-m-s"
$SvnLogPath="C:\out\s... |
School HABTM AthleticDirector
I am building a tool for assigning athletic directors (ADs) to schools. The tool has a school menu/filter which, when selected, shows a list of ADs already assigned to the school, and those yet to be assigned.
The tool can be used in two ways:
in a stand-alone fashion, where you arrive at... |
I encountered a problem at http://regexone.com/example/6?
You can view the problem by clicking the link.
There was required a regular expression to extract the method name, filename and the line number from a particular stack trace in an android development application.
I used the following regular expression to solve... |
I am a young programmer with the ability to learn more. I created a public site where a user can upload multiple pictures at once. The code works successfully and inserts the images into a MySQL database. As I improved the code further by reducing the size of multiple uploaded pictures at once, only one picture was upl... |
The working hours are saved in Database like
{"1" : "11:00 - 14:30", "2" : "17:30 - 23:00"}
Now i wrote a function like, which test is the shop is opened or close at the moment. Can someone please suggest if there is a better way to do this? And how i can check if the timing are like
{"1" : "11:00 - 14:30", "2" : "17:... |
I have three functions (out of a medium 2 digit number of functions) which use up 80% of CPU time, so I kind of wonder if there are points for optimization that I am missing.
Function 1, Extracting a bilinear interpolated point from a width * height float value image:
float ExtractBilinear(float* image, int w, int h, f... |
I wrote this code to allow users to select multiple images, and each image can be selected multiple times. It feels convoluted, though, and prone to errors, such as forgetting to do something associated with an action.
How can I make it more object-oriented or reusable?
var images = [];
function removeImage(image) {
... |
I have this little utility/helper which serializes a form into a javaScript object.
$.fn.serializeObject = function(fn) {
var o = {},
a = this.serializeArray(),
that;
$.each(a, function() {
that = this;
if($.isFunction(fn)){
that = fn(that.name, that.value);
}
if(o[this.name]... |
I've never had a serious attempt at writing an encryption algorithm before, and haven't read much on the subject. I have tried to write an encryption algorithm (of sorts), I would just like to see if anyone thinks it's any good. (Obviously, it's not going to be comparable to those actually used, given that it's a first... |
I have a files search function that iterates over a given directory until a given depth is reached and returns the found files. I did this via the Enumerate methods of the Directory class and yield return the results. Since it's very likely that I hit a directory that I can't access (e.g. system directories) or generat... |
I'm currently creating a client/server application (using Java) and I want to make it fully controllable by an input stream (currently the console). At the moment only one class have to be controlled, but I want my code to stay easy to develop.
I found a solution but I think I can do better, so that's why I post this m... |
Thats my method to test:
public LessonplannerRequest GetWeeklyLessonplanner(int schoolyearId)
{
Schoolyear schoolyear = _unitOfWork.SchoolyearRepository.GetById(schoolyearId);
DayOfWeek firstDayOfWeek = schoolyear.FirstDayOfWeek;
DateTime currentDate = DateT... |
The objective of the following PHP function is simple: given an ASCII string, replace all ASCII chars with their Cyrillic equivalents.
As can be seen, certain ASCII chars have two possible equivalents.
For example: if the function is fed the string "dvigatel" it should get you "двигател".
The problem: if I pass "dviga... |
I have the main form with a list inside and i need to open another form and edit the list in the main. Generally i'm doing something like ...
public class Form1 : Form
{
List<objectType> obj = new List<objectType>();
private void button_EDIT_BUTTONS_Click(object sender, E... |
String slm = status.getHeader("last-modified");
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE, dd MMM yyy HH:mm:ss zzz");
Date serverLastMod = null;
try {
serverLastMod = sdf.parse(slm);
} catch (ParseException e) {
Log.e("SAC XML last-modifie... |
I have the following snippet of code that redirects a user to a specific page on successful login to the application.
if(isset($this->params['url']['next'])) {
$url = parse_url(urldecode($this->params['url']['next']), PHP_URL_HOST);
if( $_SERVER['SERVER_NAME'] != $url || $url == false ) {
$pathtoredirec... |
I define a Pixel data with different size like this.
data Pixel = RGB8 Word8 Word8 Word8
| RGBA8 Word8 Word8 Word8 Word8
| RGB16 Word16 Word16 Word16
| RGBA16 Word16 Word16 Word16 Word16
| Empty
deriving (Eq)
and Num instance
instance Num Pixel where
x + Empty =... |
This code works but is there a simple / better way to do this?
It starts from a particular point (starthere) in the array, looks for first stop value to the left of start point, and the first stop to the right side.
Basically returns the closest values' positions to a start point both sides. (I'll make this a function.... |
So I wrote an asynchronous version of AutoResetEvent:
public sealed class AutoResetEventAsync {
private readonly Task<bool> falseResult = Task.FromResult(false);
private readonly ConcurrentQueue<Handler> handlers = new ConcurrentQueue<Handler>();
private readonly Task<bool> trueResult = Task.FromResult(true... |
I need to select all checked checkboxes, except checkboxes having a class .checkall.
HTML:
<input type="checkbox" value="1961" class="checkbox">
<input type="checkbox" name="checkall" class="checkbox checkall">
Script:
$("input.checkbox:checkbox:checked:not(.checkall)").each(function () {
var checkbox = $(this), m... |
I have a page with a list of items. Items have several actions assigned to them. (see screenshot).
One may choose to directly click on an icon next to each row or check a checkbox on the left hand side and click action above the list.
The issue is that after clicking an item OR checking a checkbox of several items and ... |
Exercise:
Define three new classes, called Song, Playlist, and
MusicCollection. A Song object will contain information about a particular song, such as its title, artist, album, and playing time.
A Playlist object will contain the name of the playlist and a
collection of songs. A MusicCollection object wil... |
My context is a very simple filter-like program that streams lines from an input file into an output file, filtering out lines the user (well, me) doesn't want. The filter is rather easy, simply requiring a particular value for some 'column' in the input file. Options are easily expressed with argparse:
parser.add_argu... |
I'm learning C and today I wrote a program that displays info about my hardware on ubuntu.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch, file_name[25] = "/proc/scsi/scsi";
FILE *fp;
fp = fopen(file_name,"r"); // read mode
if( fp == NULL )
{
perror("Error while opening the file.\n"... |
I'm writing a small Win32 console app that manipulates the contents of binary files. It accepts the filename as a command line parameter and writes to a file named filename.scramble
This is the first time I'm dynamically allocating memory for C strings (which I'm using since the fstream functions use const char*).
I've... |
How can I optimize this?
<cfftp connection = "myConnection"
username = "#username#"
password = "#password#"
server = "#server#"
action = "open"
timeout = "500"
stopOnError = "Yes">
<cfloop index="i" from="1" to="#ArrayLen(ImagesArray)#">
<cfset slocal = "temp\" & ImagesAr... |
Most of my slow queries on my server are due to a single "find" query. I have a collection that represents website pages. I want to be able to look up a page in the collection by URL. The caveat is that a website might have URLs that redirect to it.
I've modeled my schema (with Node.js/Mongoose) like this:
{
'u... |
Would you be kind to make me a code review? It would be nice to have some comments, whether you would have done something differently and so on. I am not sure about the way I handle the exception. Is there a better way?
@Transactional
public classServiceImpl implements Service {
private static final Logger LOG =... |
The following code works, but I'd like to re-write, so that a single index is returned, rather than a sequence of indexes visited.
Here are the defs and function.
(def usage-vec-len 13)
(def read-levels [9999 3000 2000 1000 100 90 80 70 60 50 40 30 10])
(defn sel-adj-idx
"Finds the correct position at which to bin part... |
This code takes 8 divs and races them across the screen depending on which time value the div was assigned. How can I have coded this better so my code doesn't look so amateurish?
I know I should have used something other than a hard coded 8 in my for-loop, but timeArray.length is unavailable since I am removing items ... |
I have recently just started learning Perl, so I decided to program the classic 'Guess my Number' game. I was wondering if anyone can spot any areas for improvement. As it's my first program, I expect there to be some unoptimized areas.
#!\usr\bin\perl
print"Welcome to guess my number!\n";
$compNumber=int rand 1... |
These functions are selected by the same index. I understand the index logic of what to do but I don't know how to do it well enough.
// those are buttons that will trigger different functions according by an index
button_up = jQuery('#videos_tabs-up-0' );
button_down = jQuery('#videos_tabs-down-0' );
button_up_1 = jQ... |
I want to know whether this thing I wrote in C# is a correct implementation of the state monad.
I've used it in code and it does what I expect it to do, but I'm still not quite sure if I'm doing this right, or if I just pulled something out of my ear and called it a state monad.
I would have made an IMonad<T> interface... |
I'm using the boost::units library (boost::units) and trying to make use of auto and decltype to deal with all the complicated types it produces.
I have a templated function to integrate a mathematical function (which might accept x values with units such as 1*metre) between two points:
template <class Out, class In >
... |
I am trying to track relationships among people. I came up with my own solution, but I'm wondering if there might be another way or better way of doing this. To keep it simplified, I'll post just the bare bones.
Let's say I have created the tables: person, person_relation, and people_relation for a MYSQL database using... |
I need to run over a log file with plenty of entries (25+GB) in Python to extract some log times.
The snippet below works. On my test file, I'm ending up with roughly 9:30min (Python) and 4:30min (PyPy) on 28 million records (small log).
import datetime
import time
import json
import re
format_path= re.compile(
... |
class ControllerFactory {
public function createController($controller)
{
if (file_exists($path = __DIR__ . 'app/controllers/' . $controller . '.php')) {
require_once $path;
return true;
}
}
}
It seems a bit overkill to have a class to do this. To intiate a class to ... |
I'm running into page performace issues and I believe this block is causing the biggest slowdown:
// Section menu on mouseover, hide menu on mouseout
// Can be more concise using .toggleClass?
$('section').live('mouseenter', function() {
if ($(window).width() > 1278) {
$(this).find('menu').removeClass('... |
I've managed to position the link boxes as I wanted and to apply a background to them, but I'm not sure I've done it in the most elegant or efficient way.
Is there a better way to position the elements without mixing positioning and floats? And is there a way to remove the background between the link boxes without ha... |
Given a sorted array, remove the duplicates in place such that each element appear at most twice and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example,
Given sorted array A = [1,1,1,2,2,3],
Your function should return length = 5, and A is n... |
Does the following code look okay? Want to see if anyone can spot any mistakes I may have made. This will be pulling from a pre-formatted Excel document - I have already specified all needed Cell locations.
Things I want clarified:
How many times can you invoke SetInfo and did I use it more than needed? I was under th... |
I wrote an infinite scrolling scrolling plugin for an app I'm developing. When requesting the second 'page' from the server, I loop through each image, and give it a very basic onload function.
// I will have the result in a variable called data
// Fetch each image from result
$images = $( data.content ).find('img');
/... |
I have an sql table with multiple fields and 4 of them are enums. I wrote a script that runs thought the table and retrieve the enums and put them in a 2 dimension array.
Unfortunately this script is extreamly slow and I can't fix it.
<?php
require_once('mySQL_Connect.php');
$con = ConnectToDataBase();
if ($con == f... |
I've just started programming with JavaScript and I am currently working on this hobby website project of mine. The site is supposed to display pages filled with product images than can be "panned" to either the left or right. Each "page" containing about 24 medium sized pictures, one page almost completely fills out a... |
This question is about improving my C++ coding skills. I was asked to implement a simple static integer stack in C++ as an assignment. I've come up with the following code:
class myStaticIntStack
{
int stackSize;
int storedElements;
int *elements;
public:
myStaticIntStack();
myStaticIntStack( int... |
Any idea how to write this code better."the html is nested tabs"
Two selectors and two similar events, in a function would be better or a pattern to reduce lines. eg .jsbin
$(function() {
var $items = $('#vtab>ul>li'),
$items2 = $('#vtab2>ul>li');
$items.mouseover(function() {
var index = $items.index($... |
I'm pretty new to programming in general. I work with MySQL at my job but my knowledge of scripting language is rudimentary at best. I've been learning JavaScript via Codecademy but I got bored and set out on my own. I made this Tic Tac Toe game, which is purely text-based and predictably boring. I was just wonderi... |
I have a situation where I have a fixed point number that I want to convert to and from a floating point number. Specifically it is the SANE_Fixed type from the SANE API. Here is the what the documentation says (I grabbed the bits I think are relavant):
SANE_Fixed is used for variables that can take fixed point valu... |
Please review my following code for DAO layer.
public List<Channel> getListOfChannels() throws DataAccessException {
// will have the channel in form of List
// to hold the channels list
List<Channel> listChannels = null;
Connection conn = null;
Statement statement = null;
... |
This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class represents the entire book, and has functions to download and render individual pages. This class is supposed to make things ru... |
After some 'digging' into the dark corners of legacy code I've found class, which handles INI files. It does reading and writing to the file, but I haven't found any exception handling logic. What kind of potential problems, if any, can you detect and what is your suggestion/advise for improving the code, based on thes... |
Well, i'm starting a function to 'mess' with a image gallery, i made an example
i wanna know if the way i'm doing is realy the BEST way, the function work perfect, but i fill that can be better, something more dynamic, like never flow over the edge, and mess with the number of images that user places inside the gallery... |
Can someone help in making this clock code more modular so I will be able to use it in other bigger projects for example: turn into a c function. Here is the code:
#include <stdio.h>
#include <time.h>
#include <windows.h>
COORD coord = {0, 0};
void gotoxy (int x, int y)
{
coord.X = x; coord.Y = y; SetConsoleCursor... |
#!/usr/bin/env python
import os, sys
variable = sys.argv
def enVar(variable):
"""
This function returns all the environment variable set on the machine or in active project.
if environment variable name is passed to the enVar function it returns its values.
"""
nVar = len(sys... |
I'd like to know if I'm doing profile configuration in the wrong place or in the wrong way.
I'm following the Onion Architecture, so that restricts the direction of my dependencies towards the center.
Core
My domain model and AutoMapper facade:
namespace Core.Domain
{
public class MyModel
{
// model st... |
(defn merge [pred left right]
(loop [v [] l left r right] ; v is a vector, so conj will append to the end
(if (and (seq l) (seq r)) ; if both left and right are not empty
(if (pred (first l) (first r))
(recur (conj v (first l)) (rest l) r)
(recur (conj v (first ... |
I'm trying to make a card game, using OOP style. I decided to make suit a class rather than an enum as I would first have done. How am I doing so far? Am I over-complicating things by making it a class?
namespace Cards
{
class Suit
{
public:
Suit();
~Suit();
std::string GetName(bool plural, bool capital) c... |
I have a Ruby class into which I want to include both class and instance methods. Following the pattern described in "Ruby Pattern: Extend through Include", I'm currently using the following:
class SomeObject
include SomeObject::Ability
def self.some_builder_method(params)
# use some_class_method ...
end
e... |
I have a class something like the following:
class ItemManager {
List<Item> items;
public ItemManager() {
items = Database.retrieveItems();
}
}
An item has several attributes, so much so that I used a Builder class instead of a typical constructor(Like the builder classes found in Joshua Bloc... |
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
For example:
s result
"Hello World" 5... |
I recently started running but hate running both in the quiet and with music, so i've been listening to podcasts. Unfortunately, I've caught up with all my favorites and so I've started listening to some iTunesU courses, but unfortunately (again) very few of them have audio-only versions.
I wrote a shell script to cop... |
Is there a better way to write this in vs2010 C#?
public bool IsAccept()
{
//check the status is accept
if (Status == null)
return false;
return Status.ToLower() == "accept";
}
public bool IsRefer()
{
//check the status is refer
if (Status == null)
return false;
return Status.To... |
I'm new to front-end development and now I'm learning JavaScript with jQuery.
I couldn't understand JavaScript's classes and objects and jQuery plugins, but after reading some articles and examples I wrote simple notifications system.
(function ($) {
var notification = function (title, msg, duration) {
var ... |
I am writing a specialized version of the cross correlation function as used in neuroscience. The function below is supposed to take a time series data and ask how many of its values fall in specified bins. My function xcorr works but is horrifically slow even. A test data set with 1000 points (and so 0.5*(1000*999) in... |
I made this simple game code. Can you please give me some advice on how I can improve it?
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include <time.h>
#include <windows.h>
void main ()
{
printf("\t\tWelcome to our gessing game\n\n\n");
printf("the computer choose a random number between 1-99, try t... |
Premise: Write a program that counts the frequencies of each word in a text, and
output each word with its count and line numbers where it appears. We
define a word as a contiguous sequence of non-white-space characters.
Different capitalizations of the same character sequence should be
considered same word (e.g. P... |
Given a number represented as an array of digits, plus one to the
number.
input expected
[8,9,9,9] [9,0,0,0]
[1,0,0,0,0] [1,0,0,0,1]
[9,8,7,6,5,4,3,2,1,0] [9,8,7,6,5,4,3,2,1,1]
The following is my C++ code:
vector<int> plusOne(vector<int> &digits)
{
... |
Given a sorted linked list, delete all duplicates such that each element appears only once.
For example:
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
The following is my code:
struct ListNode {
int data;
ListNode *next;
ListNode(int x) : data(x), next(NULL) {}
};
ListNode *getNextE... |
I am trying to delete a large folders (with many levels of subfolders) over a network (i.e, on a remote machine).
I have the following code and it takes 10 minutes. Is there a way to improve this drastically?
public static boolean deleteDirectory(File directory) {
File[] files = directory.listFiles(); // Valu... |
I've designed the basics of an admin page I'd like to use for a small website. I'd like to know if I'm using the language properly. Please rip apart the code and tell me what I could do better.
Admin page code, file called "index.php" (just the file name in my "netbeans" folder):
<!DOCTYPE html>
<html>
<head>
<me... |
I created this version of Hangman in Python 3. Does anyone have any tips for optimization or improvement?
import random
HANGMAN = (
'''
-------+''',
'''
+
|
|
|
|
|
-------+''',
'''
-----+
|
|
|
|
|
-------+''',
'''
-----+
| |
... |
Update: Great answers up to now, but I would still love to have a bit of review about possibility of variable caching and the filter I'm using for rows and page sets!
After seeing a lot of Paginator plugin that never fit my needs, I've decided to create my own. I have followed the jQuery Authoring advices.
Configurati... |
I've realized a jQuery Plugin recently and made a basic default CSS for it.
As I'm mainly a server-side guy, I'm not too familiar with CSS and would like to have insight about what could be improved.
The main issues I've targeted are :
Are the CSS selectors appropriate, knowing that this CSS is meant to be on a plugin... |
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1->1->2->3, return 2->3.
The following is my code:
ListNode *getNextElement(ListNode *head, bool& repeated){
while ((he... |
In my system I frequently require data by Ajax requests. For example, different lists, content of modal dialogs, etc. This data can't be changed after request, so I wrote cache mechanism which stores Ajax result and then before Ajax request checks is there stored data.
Here is example:
YFeX.cache = { }; // YFex is my o... |
I have a Edit/Details form which has 4 user related fields. On click of Save, I save the edited fields to local storage (if supported) and display the same values in the Details view.
Below is the code which does that;
var UserDataObj = {
name:"John",
email:"john@example.com",
phone:"9999999999",
desc:"some descripti... |
The required output is stated just before the main() function. Is there a better way to achieve it? I feel like I am repeating code unnecessarily but am unable to find a better way to get the result. Not squeezing the code too much, like one liners, but reasonably using better logic.
#!/usr/bin/env python
# -*- coding:... |
I've started to program a state machine on a PIC18F2550 microcontroller. In each state of my machine, there is a designated block of code that runs for a specific amount of real time, such as 20 or 30 seconds. To do this, I use a countdown timer that is decremented once every second. Depending on the state the machine ... |
This is in continuation to a question I asked here. Given the total number of nodes (employees) and the adjacency list (friendship amongst employees), I need to find all the connected components.
public class Main {
static HashMap<String, Set<String>> friendShips;
public static void main(String[] args) throws... |
Below is an implementation of Dijkstra's shortest path algorithm. It's input graph is represented as an association list of source nodes to assoc of target node and arc weight.
My question is about the following, am I missing a way of simplifying min-path function used in reduce? Maybe the great and powerful loop could... |
I need to connect different Task with a double linked list and different Dependencies which affect a calculation for which I need the values of both Task:
public class Task {
private List<Dependency> parents = new ArrayList<Dependency>();
private List<Dependency> children = new ArrayList<Dependency>();
//U... |
I have 2 classes that should run a service when calling their Start method, but before it they should:
Copy items to F folder
Open S service in remote server if it's not opened already
Run #SN service in remote server
They differ in 1 & 3 steps:
In 1st step each one of them may copy different items depending on some... |
I'm brand new to JavaScript and jQuery and I feel like there's probably a better way to do this. It seems that the way I designed it may not be very optimal once you get a thousand entries in the list but I do like the fact that it's a live search.
Note: I tried changing the style of the <option>'s to display:none but... |
Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, and performance wasn't really considered (or I wouldn't have written this in PHP in the first place).
Thoughts? Criticism... |
This piece of code I have written works, but I don't think its the best solution.
What I am doing is check if a certain radio is checked if it is show this div if else show this div if this radio is checked etc.
Can someone point me in the right direction on this one? I would love to know how to write less do more.
$(... |
The output is a random sequence, and the input is the sum of the sequence.
My solution is generating a random number rand_num from (0, sum_seq) at first, then draw another number randomly from (0, sum_seq - rand_num). By the way, all random numbers are integers.
import random
rand_list = [] # Random sequences buffer
d... |
I was playing with some of the wonderful new C++11 features and tried to reimplement a function reversed that would behave just like the one in Python to allow reverse iteration on bidirectional iterables.
And to clarify since I'm been told that I was unclear, that reverse function would be used in range-based for loop... |
I need to refactor this code, targeted to Google Chrome (current+) to make it manageable going forward.
Here is a working JSBin of the idea.
The messiness comes from determining the accurate number of lines of text, and the real heights of elements. I know I am passing this information around too much, without enough s... |
This is the code:
public DateTime GibSomeStartDate(IEnumerable<int> partnerNumbers, DateTime startTime)
{
return (from contract in this.databaseContext.Contract
where partnerNumbers.Contains(contract.Pnr) && contract.SomeDateTime >= startTime
select contract.SomeDateTime).Min();
}
databa... |
This method assigns the value of a specified column in a DataRow to specified property in an object.
I have 3 conditionals handling exceptions, and I want these conditions to throw exceptions.
The final condition just allows the use of a conversion method if it exists. Is there a better way to test for and throw the ... |
I am very new to GUI programming, and I'm pretty sure I'm doing it wrong. Please take a look at my code, and suggest some changes. I feel it's way too complicated for what it's actually doing.
For example, here is my main class:
'''
Written by blacksheep
March 4, 2013
'''
#################
# IMPORTS #
#########... |
I have a class, which stores an enum to track if my object is modified, newly created, or no change. If the object is modified, I have additional booleans for each field that is modified.
For instance,
public enum status
{
NoChange,
Created,
Modified
}
private bool? name;
private bool? address;
...
private... |
I've made my first simple game in HTML5. Unfortunately, it runs so slowly. But there are only few rectangles! On my PC, frame rate is between 20 and 25. I expected something like 60-70 but no 20! You can see this game here: http://mygames.jcom.pl/ (and you can see code by clicking Ctrl+Shift+C in Chrome). What can I do... |
Is there a cleaner way to write:
def b_fname
if mdes_version_is_after?(3.0)
result = c_fname
else
result = response_for("#{birth_baby_name_prefix}.BABY_FNAME")
end
if result.empty?
result = 'your baby'
end
result
end
|
What I want to do is; without leaving the chain, execute some custom/external code (and continue) within the chain. Otherwise; in a deep chain, I will have to re-query for the DOM element to get back where I've left.
The method below allows to execute custom code inside a jQuery chain synchronously or asynchronously.
/... |
The code already works, but I just want tips for improving.
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class Calculator
{
public static void main(String[] args)
{
double initialPrice = 0.00;
double commissionRate = 0;
double discountRate = 0;
initialPr... |
This is a method that calls a web service, it uploads an audio file and fetches metadata back.
While the advantage is that there is only one method to call there are a few concerns about it :
There is some UI-related code (upload progress)
Some audio-related code (format detection)
Web-service related code (first purp... |
I am trying to write a Python script that download an image from a webpage. On the webpage (I am using NASA's picture of the day page), a new picture is posted everyday, with different file names. After download, set the image as desktop.
My solutions was to parse the HTML using HTMLParser, looking for "jpg", and wri... |
Background
A subclass of java.util.Properties attempts to recursively resolve configured properties:
prop_a=Prop A is ${prop_b}
prop_b=Prop B is ${prop_c}
prop_c=Prop C.
After reading the file, prop_a should be Prop A is Prop B is Prop C.
Property Reference Semantics
Nest properties are not allowed, making the follo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.