Posts

linux - Bash check if all files in a folder are writable by www-data -

i have logs folder , log files owned root , need them owned www-data . i'm writing script check if owned www-data = writable user. #!/bin/bash rootfiles=$(ls -la /tmp/logs/ | grep root | sed -e 's/\s*$//') if [[ ! -z "$rootfiles" ]]; exit 1 fi exit 0 this works fine, if assume there'll no file contains word root in it's name, , that's not root www-data . how make more robust? you can use find find out: find /tmp/logs -not -user www-data but, to change owner of files, can use recursive chown : chown -r /tmp/logs/* www-data

Java program to find the IP addresses of the following websites: Facebook , google , yahoo in the same try and catch -

here code 1 website need make multiple ip's in same try , catch package javaapplication1; import java.net.inetaddress; import java.net.unknownhostexception; public class javaapplication1 { public static void main(string[] args) { try { inetaddress[] addresses = inetaddress.getallbyname("google.com"); (inetaddress address : addresses) { system.out.println(address); } } catch (unknownhostexception ex) { system.out.println("could not find"); } } } make list of facebook,google , yahoo iterate on list , use inetaddress.getallbyname(list.get(index)) arraylist<string> list = new arraylist<>(); list.add("facebook");// can add more urls (string ip : list) { try { inetaddress[] addresses = inetaddress.getallbyname(ip); (inetaddress address : addresses) { ...

python - Diffie-Hellman Parameters and safety -

i want create own safe connection voip app. now looking key exchange seems more tricky encrypting/decrypting. are there better approaches diffie-hellman in practice ? i understand concept of diffie-hellman think needs right values safe since natural numbers guessed. how can values using python, , safe key guessing? please me background informations / inspiring. diffie-hellman key exchange, called exponential key exchange, method of digital encryption uses numbers raised specific powers produce decryption keys on basis of components never directly transmitted, making task of would-be code breaker mathematically overwhelming. the serious limitation of diffie-hellman in basic or "pure" form lack of authentication. communications using diffie-hellman vulnerable man in middle attacks. ideally, diffie-hellman should used in conjunction recognized authentication method such digital signatures verify identities of users on public communications medium. more l...

ruby on rails - No routes matches, empty action -

i've got rails application inherited previous coder. generates sortable tables , has helper function sortable sortable ends this link_to title, link, { :class => css_class, :"data-direction" => direction, :"data-sort" => column, :"data-page" => params[:page].to_i.zero? ? 1 : params[:page].to_i, :"data-title" => params[:title], :"data-search-id" => params[:search_id], :title => "sort `#{title}` #{direction}"} link conatins fields :sort , :direction when try create sortable table written controller i'm getting error (no route matches {:sort=>:company_name, :direction=>:asc, :controller=>"company"}) don't understand how code working on other controllers , fields controller , action

at - job added via PHP to queue not working -

i have small script in php set at jobs exec() . php can execute exec() , @ jobs added queue, because see them on @ queue list. echo "/usr/local/ffmpeg1.1/bin/ffmpeg -i '/data/html/admin.domain.com/httpdocs/raw/gym/gym_part_1.avi' -c:v libx264 -vsync 2 -strict -2 /data/html/domain.com/httpdocs/videos/galleries/gym_part_1.mp4" | @ +2 minutes this doesn't work. gets queued doesn't work. if i run on bash works perfectly user i'm logged in or apache user - adding sudo -u apache before at . echo "/usr/local/ffmpeg1.1/bin/ffmpeg -i '/data/html/admin.domain.com/httpdocs/raw/gym/gym_part_1.avi' -c:v libx264 -vsync 2 -strict -2 /data/html/domain.com/httpdocs/videos/galleries/gym_part_1.mp4" | sudo -u apache @ +2 minutes linux , @ version linux linux web1.com 2.6.18-400.1.1.el5 #1 smp thu dec 18 00:59:53 est 2014 x86_64 x86_64 x86_64 gnu/linux at at version 3.1.8

c++ - Can we introuduce aliases for template specializations? -

can introduce alias partial specialization? mean that: template <class t, class v> class a{ }; typedef template <class t> a<t, int> mypartialspecializa<t>; int main(){ } demo but doesn't work. standard that? you need alias template this template <class t, class v> class a{ }; template <class t> using mypartialspecializa = a<t, int>; int main() { mypartialspecializa<double> a; }

android - OkHttp + Retrofit offline cache not working -

i'm requesting json data 2 servers. okhttp doesn't cache responses first server, responses second server caching properly. response first server, cache not working reason: <--- http 200 cache-control: public, max-age=2230 content-type: application/json; charset=utf-8 expires: sat, 28 mar 2015 11:34:13 gmt last-modified: sat, 28 mar 2015 10:34:13 gmt vary: * server: microsoft-iis/7.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net access-control-allow-origin: * date: sat, 28 mar 2015 10:57:01 gmt content-length: 1381 okhttp-selected-protocol: http/1.1 okhttp-sent-millis: 1427540192625 okhttp-received-millis: 1427540192940 <--- end http (1381-byte body) response first server when device offline: ---> http cache-control: public, only-if-cached, max-stale=2419200 ---> end http (no body) <--- http 504 <--- end http (0-byte body) response second server, cache works: <--- http 200 content-type: application/json; charset=utf-8 date: sat, 28 mar 20...