Deleting duplicate for one field – group by and order by

By Mihir

I have daily price of some items stored in a table, for each product ID along with date. I want to delete newer price record if it’s same as previous. Or moving from older to newer, if the next record for that product ID has same price, I want to delete it. My primary key includes all three fields so not much of use here.

This is my table structure.

productID  Price    Rdate
1           210     2015-05-01
2           55      2015-05-01
3           9       2015-05-01
1           211     2015-05-02
2           53      2015-05-02
1           211     2015-05-03

productID – INT (foreign key)


Rdate – DATE

In this example, I want to delete the last record, since the price is same as previous date.

Is it possible to delete it using a single query? Even if I have to loop the query for each ID, it’ll be fine.

Source: Stack Overflow


Codeigniter passing dynamic data from controller to view. And Mapping values to controller array variable

By user254153

I want to get the array from controller to views which is dynamic.



 $a = array(array('category_id'=>'3', 'name'=>'car'),array('category_id'=> '5', 'name'=>'bike'));
 $data['category'] = $a;
 foreach($a as $val){
     $data[$val['name']] = $this->home_model->get_product($val['category_id']);

View (main.php)

 foreach($category as $val){
    foreach($val->name as $value){     //undefined variable passedto foreach, But when I var_dump variable are printed in controller but cannot get in views. How to map the value, to value that is passed from controller.


Source: Stack Overflow


Rainmaker Rewind: Henry Rollins on Entrepreneurial Art

By Caroline Early

Rainmaker FM rewind

We have a special treat for you on Rainmaker FM this week …

Music legend and entrepreneur Henry Rollins joins Brian Clark on Unemployable to discuss how his career (including his role as frontman of Black Flag) has thrived due to a DIY-producer ethic, why he formed his own publishing company, and how he became a self-made media personality.

There’s a lot of other great content on the network these days, so be sure to check out the rest of the shows highlighted in this week’s edition of Rainmaker Rewind.

  1. Unemployable. Henry Rollins joins Brian Clark for a second time to discuss music, entrepreneurship, and the art of self-promotion: Henry Rollins on Entrepreneurial Art
  2. Copyblogger FM. Sonia Simone dives into why focusing on email opt-ins is one of the most important content marketing practices: Content Marketing Best Practices: Getting Email Opt-Ins
  3. The Digital Entrepreneur. Brian Clark and Jerod Morris explain how you should be using social media to connect with your audience: Does Your Social Media Strategy Need a Mindset Shift?
  4. Hack the Entrepreneur. Jon Nastor chats with Paul Kortman about the transition from office life to entrepreneur life: The Reluctant Path to Becoming an Entrepreneur
  5. Elsewhere. Charlie Gilkey welcomes Sonia Simone to The Creative Giant Show to chat about marketing, careers, and digital business: Sonia Simone on The Creative Giant Show
  6. The Missing Link. Jabez Lebret and Steve Anderson discuss building authority and becoming an influencer on LinkedIn: An Influencer’s Guide to Building Your Authority on LinkedIn
  7. Zero to Book. Jeff Goins and Pamela Wilson review the various means of publishing and identify which route is ideal for authors — especially first-timers: Artisanal Publishing and the Hidden Power of the Beginner’s Mind
  8. The Showrunner. Jerod Morris and Jon Nastor explain how and why booking guests for your podcast is well-worth the sometimes overly complicated booking process: How to Execute Engaging Podcast Interviews
  9. Confessions of a Pink-haired Marketer. Sonia Simone talks web traffic, sales pages, and the one element you need to master if you want your content to work: The Context of a Successful Content Strategy: The Harpoon and the Net
  10. Youpreneur. Chris Ducker shares the top five reasons why originality is so important in business and gives away one of the keys to long-term business success: How Being ‘Original’ Can Boost Your Business Faster than Anything

And, one more thing …

If you want to get my Rainmaker Rewind picks of the week sent straight to your favorite podcast player, subscribe right here on Rainmaker FM.

See you next week.

The post Rainmaker Rewind: Henry Rollins on Entrepreneurial Art appeared first on Copyblogger.

Source: Copy Blogger


python make_archive adding . file

By Orannis396

I have a python script for creating archives of particular cross-platform builds of a project and i am using the python 2.7 shutil to help make archives of the builds.
The issue is that it is adding a random file called . to the archive even though there is no such file in the directory. This then causes an error when extracting.
The code is as follows

windows_zipname = os.path.join(config['build-folder'], '{}-win-{}'.format(config['game-name'], config['version']))
osx_zipname = os.path.join(config['build-folder'], '{}-osx-{}'.format(config['game-name'], config['version']))

shutil.make_archive(base_name=windows_zipname, format='zip', root_dir=win_folder, verbose=True, logger=logging.getLogger(''))
shutil.make_archive(base_name=osx_zipname, format='zip', root_dir=osx_folder, base_dir="*",verbose=True, logger=logging.getLogger(''))

Thanks for your time.

Source: Stack Overflow


Update JSF Component with Primefaces

By user2545722

I know this has been asked many times, but mainly with ajax. I can’t use ajax in my project.

I want to create an event on selectOneMenu A and update selectOneMenu B.

<p:selectOneMenu id="A" binding="#{bean.slmA}" >
    <f:selectItems value="#{bean.itemsA}"/>

<p:selectOneMenu id="B" binding="#{bean.slmB}">
    <f:selectItems value="#{bean.itemsB}"/>

I already used the valueChangeListener with a method that adds elements to itemsB (also onchange =”submit()”) but slmB doesn’t update.

Source: Stack Overflow