Jump to content

dsp77

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by dsp77

  1. Hello, I have this piece of code that works as intended: $chars = array('1','2','3'); $cnt = count($chars); $strings = array(); for ($f = 0; $f < $cnt; $f++) { for ($s = 0; $s < $cnt; $s++) { for ($t= 0; $t < $cnt; $t++) { $strings[] = $chars[$f] . $chars[$s] . $chars[$t]; } } } print_r($strings); The problem i'm facing is that i want to transform it in a function where i pass the chars and the nr of elements in the permutation in the above code if i want more elements ill duplicate the for loop and so on. For example i'm trying to create a function like: function perm($chars,$nrElements){ } thank you in advance
  2. i swear i did that at one point, but thank you!!! now i got it
  3. I took in consideration that some ppl might find the stripes buggy and i noted to add a JS bg changer with different circles, squares animals:) etc
  4. thank you Adam, I made a few changes in moving the api key and the url into the class but i cannot make the __construct i looked over the manual but i cannot make it work still need 2 understand more about class logic. <?php class shortenGoogle { public $google_api_key = 'sadasdfasfasfds'; const GOOGLE_ENDPOINT = 'https://www.googleapis.com/urlshortener/v1'; function shortenUrl($longUrl){ // initialize the cURL connection $ch = curl_init(self::GOOGLE_ENDPOINT.'/url?key='.$this->google_api_key); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // create the data to be encoded into JSON $requestData = array( 'longUrl' => $longUrl ); // change the request type to POST curl_setopt($ch, CURLOPT_POST, true); // set the form content type for JSON data curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // set the post body to encoded JSON data curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData)); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } function expandUrl($shortUrl){ // initialize the cURL connection $ch = curl_init(self::GOOGLE_ENDPOINT.'/url?key='.$this->google_api_key.'&shortUrl='.$shortUrl.''); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // tell cURL to ignore the SSL certificate in case it expires curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } } $short = new shortenGoogle; $url = $short->shortenUrl('http://www.google.com/'); $url2 = $short->expandUrl('http://goo.gl/fbsS'); print_r($url); print_r($url2); ?>
  5. with time i will add the free themes to, now i'm still working to retrieve templates automatically with all descriptions.
  6. I created a functional class that shortens or expands the URL using google's shortening service. The class works but i feel like i can optimize it more but i don't know really how because i'm new in using classes. here is the code define('GOOGLE_API_KEY', 'khjdaskjfsjkdhgfbsdhgsj'); define('GOOGLE_ENDPOINT', 'https://www.googleapis.com/urlshortener/v1'); class shortenGoogle { function shortenUrl($longUrl){ // initialize the cURL connection $ch = curl_init(sprintf('%s/url?key=%s', GOOGLE_ENDPOINT, GOOGLE_API_KEY)); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // create the data to be encoded into JSON $requestData = array( 'longUrl' => $longUrl ); // change the request type to POST curl_setopt($ch, CURLOPT_POST, true); // set the form content type for JSON data curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // set the post body to encoded JSON data curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData)); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } function expandUrl($shortUrl){ // initialize the cURL connection $ch = curl_init(sprintf('%s/url?key=%s&shortUrl='.$shortUrl.'', GOOGLE_ENDPOINT, GOOGLE_API_KEY)); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // tell cURL to ignore the SSL certificate in case it expires curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } } $short = new shortenGoogle; $url = $short->shortenUrl('http://www.google.com/'); print_r($url);
  7. Hello, I have a beta site with wordpress themes from other sites, i'm still working on it. http://www.wp-skin.com/ The hover is horrible i know ill try my best, the usage is intended until final touch. Thanks
  8. that's funny, so easy that i didn't think about it. Thanks Man
  9. i managed to do a code for all pictures but i still cannot make them disappear after clicking other picture $('#echipa_left a').click(function (e) { e.preventDefault(); $('#echipa_' + this.id).css('display','block'); });
  10. hello, i have a gallery that shows the hidden div after click, the problem is that i have around 20 pictures and i'm not able to hide the selected picture after the user selects other and so on. here is the piece of the code: $('.id2').one("click",function() { $('#test').css('display','block'); }); $('.id3').one("click",function() { $('#test3').css('display','block'); }); and the html <div id="big_photo"> <div id="test" style="display:none;"> <img src="images/team/team1.jpg" rel="images/team/team11.jpg" /> <p>Name</p> <span>title</span> </div> <div id="test3" style="display:none;"> <img src="images/team/team2.jpg" rel="images/echipa/team22.jpg" /> <p>Name2</p> <span>title2</span> </div> </div> and so on.
  11. i made a tweak on the object element and it works, the problem now is how to make the pointer to show that there is a link there. I made in flash a hand cursor but it persists after i move the mouse out of the flash. i uploaded the fla file. [attachment deleted by admin]
  12. if you look at the code i'm using "wmode='transparent'"
  13. the java script searches for the first a href in #letter and shows a hidden div, the problem is that flash cannot launch this call and i want the href to be on top of the flash, i tried with z-index but no luck.
  14. i'm trying to place the href over the object because i need to call a javascript event. the html works in firefox but not in others #letter { position:relative; top: -15px; left: 0px; width:250px; height:175px; float:left; } #letter a { width:250px; height:175px; display:block; cursor:pointer; } <div id="letter"><a href="#" title="click"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="250" height="175" id="plic" align="middle"> <param name="movie" value="media/plic.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="transparent" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="media/plic.swf" width="250" height="175"> <param name="movie" value="plic.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="transparent" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--<![endif]--> <a href="http://www.adobe.com/go/getflash"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </a> </div> any advise?
  15. i made an animated gif but it sucks and its not transparent on the edges. [attachment deleted by admin]
  16. the script shows an alternative image on mouse over using the rel atribute the second part takes a hidden div and shows the content in another place on the same page but when i hover the image the image doesn't change, the hover on the hidden div works, but after moving it on click in other place the hover doesn't work in the new place. I think it might be the document ready script because i alter the page after ready but i'm not sure, any advise? thank you $(document).ready(function(){ $(function() { $('img[rel]').hover(function() { $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('rel')).attr('rel', $(this).attr('tmp')).removeAttr('tmp'); }).each(function() { $('<img />').attr('src', $(this).attr('rel')); }); $('.id2').one("click",function() { var newPara = $('#test').html(); $('#big_photo').append(newPara); }); }); });
  17. i tried a few code that i found on the internet but none was relevant to what i need, so i tried to modify, see how they work but with no success. i think the logic would be like this: declare a fixed point x y on the pic then rotate the pic from that point like a pivot.
  18. Hello, this is new frontier for me with jquery animate, i tried to make a letter pinned to a wall and oscillate a few degrees but with no success i added a pic with an example. any help please? [attachment deleted by admin]
  19. the folder resides in /var/www/html and DocumentRoot "/var/www/html" taken from httpd.conf
  20. i deleted the content of the folder and added a index.html file with hello h1, after accessing the link http://199.58.44.xxx/folder/index.html i get Not Found The requested URL /competenteincomunicare.ro/ was not found on this server. i think i need to make some changes in httpd.conf
  21. i have an wordpress install on that folder. the thing is that the page is not found and i get 404 error
  22. i have a centos server and i want to access http://199.58.44.xxx/folder/ the /folder/ exists on the server but when i access it i get 404 error. i think i need 2 play with httpd conf how can i make it accessible?
  23. thank you salathe this is the code i was trying to achieve
  24. from what i understand is ok like this? when i code i'm trying to make the simplest and fastest code that's why asked if can be one preg_replace doing all the job.
  25. i'm having trouble in combining the 2 preg_replace into 1. basically i have a string witch strange chars, first i remove all except alphanumeric chars and the remaining string has 1 or 2 spaces and i replace them with dash. strtolower(preg_replace('/\s+/', '-', preg_replace("/[^0-9a-zA-Z]/i", ' ',$a['item'])));
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.