32 Matching Annotations
  1. Jun 2024
  2. Mar 2024
  3. Jan 2024
    1. https://web.archive.org/web/20240104082611/https://alexcabal.com/posts/standard-ebooks-and-classic-web-tech

      first published #2022/02/11

      Apart from the framing of this post more as an apology than as a show of strength of keeping things simple and sturdy, interesting nuggets: Epub ebooks are xhtml and static so rapidly served without the need for a fancy framework or even a database. Flat texts are small, and their current collection fits in RAM entirely. PHP is used without frills. All in all a strong call to keep things simple, and to embrace my current use of php for local tools too: it's very fast.

      Also makes me wonder: #openvraag what can one do with Epub books outside an ebook reader, in terms of excerpting e.g. and ripping things out for re-use elsewhere. I've got loads of them on my laptop

  4. May 2023
    1. ```php

      $record) { if ($name<>"count" and $name<>"specials") { foreach ($record["site"] as $sitelink) { $site[$sitelink["dbname"]]=$sitelink["url"]; } } if ($name==="specials") { foreach ($record as $sitelink) { $site[$sitelink["dbname"]]=$sitelink["url"]; } } } /* Open files */ $fp = fopen('data/'.$entity_proc.'.ttl', 'w'); fwrite($fp, "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"); fwrite($fp, "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"); fwrite($fp, "@prefix skos: <http://www.w3.org/2004/02/skos/core#> .\n"); fwrite($fp, "@prefix wd: <http://www.wikidata.org/entity/> .\n"); fwrite($fp, "@prefix wdt: <http://www.wikidata.org/prop/direct/> .\n"); fwrite($fp,"\n"); fwrite($fp,"<http://www.wikidata.org/categories> rdf:type skos:ConceptScheme ;\n"); fwrite($fp," skos:prefLabel \"Wikidata categories\"@en .\n\n"); // echo $list_entities."\n"; $url = "https://www.wikidata.org/w/api.php?action=wbgetentities&ids=".$entity_proc."&props=labels|aliases|sitelinks&format=php&utf8="; $a = unserialize(file_get_contents($url)); foreach ($a["entities"] as $entity=>$data_entity) { fwrite($fp,"wd:".$entity." rdf:type skos:Concept ;\n"); fwrite($fp," skos:inScheme <http://www.wikidata.org/categories> "); if (isset($data_entity["labels"])) { foreach ($data_entity["labels"] as $label) { fwrite($fp,";\n skos:prefLabel \"".$label["value"]."\"@".$label["language"]." "); } } if (isset($data_entity["aliases"])) { foreach ($data_entity["aliases"] as $item) { foreach ($item as $label) { fwrite($fp,";\n skos:altLabel> \"".$label["value"]."\"@".$label["language"]." "); } } } foreach ($data_entity["sitelinks"] as $item) { if (in_array($item["site"],$array_sources)) { /* GET BROADER CATEGORIES */ $repeat_query=true; $cmcontinue=""; while ($repeat_query==true) { $repeat_query = false; $url_wiki = $site[$item["site"]]."/w/api.php?action=query&generator=categories&titles=".urlencode($item["title"])."&prop=pageprops|categoryinfo&format=php&utf8=".$cmcontinue; $b = unserialize(file_get_contents($url_wiki)); if (isset($b["continue"]["cmcontinue"])) { $repeat_query = true; $cmcontinue = $b["continue"]["cmcontinue"]; } if (isset($b["query"]["pages"])) { foreach ($b["query"]["pages"] as $broadcat) { if (isset($broadcat["pageprops"]["wikibase_item"])) { if (!isset($broader[$broadcat["pageprops"]["wikibase_item"]])) {$broader[$broadcat["pageprops"]["wikibase_item"]]=$broadcat["title"];} // fwrite($fp,"<http://www.wikidata.org/entity/".$entity_proc."> <http://www.w3.org/2004/02/skos/core#broader> <http://www.wikidata.org/entity/".$broadcat["pageprops"]["wikibase_item"]."> <http://www.wikidata.org/categories/".$item["site"]."> .\n"); } } } } /* GET NARROWER CATEGORIES */ $repeat_query=true; $cmcontinue=""; while ($repeat_query==true) { $repeat_query = false; $url_wiki = $site[$item["site"]]."/w/api.php?action=query&generator=categorymembers&gcmtitle=".urlencode($item["title"])."&gcmtype=subcat&prop=pageprops|categoryinfo&format=php&utf8=".$cmcontinue; $b = unserialize(file_get_contents($url_wiki)); if (isset($b["continue"]["cmcontinue"])) { $repeat_query = true; $cmcontinue = $b["continue"]["cmcontinue"]; } if (isset($b["query"]["pages"])) { foreach ($b["query"]["pages"] as $narrowcat) { if (isset($narrowcat["pageprops"]["wikibase_item"])) { if (!isset($narrower[$narrowcat["pageprops"]["wikibase_item"]]) or $item["site"]=="enwiki") {$narrower[$narrowcat["pageprops"]["wikibase_item"]]=$narrowcat["title"];} // fwrite($fp,"<http://www.wikidata.org/entity/".$entity_proc."> <http://www.w3.org/2004/02/skos/core#narrower> <http://www.wikidata.org/entity/".$narrowcat["pageprops"]["wikibase_item"]."> <http://www.wikidata.org/categories/".$item["site"]."> .\n"); } } } } } } } $prevalue=""; foreach ($broader as $target=>$value) { fwrite($fp,";".$prevalue."\n skos:broader wd:".$target); $prevalue=" # ".$value; } if ($prevalue!=="") {fwrite($fp,$prevalue);} $prevalue=""; foreach ($narrower as $target=>$value) { fwrite($fp,";".$prevalue."\n skos:narrower wd:".$target); $prevalue=" # ".$value; } if ($prevalue!=="") {fwrite($fp,$prevalue);} fwrite($fp,".\n\n"); fclose($fp); ?>

      ```

  5. Dec 2022
  6. Jul 2022
    1. PHP est un langage de script utilisé le plus souvent côté serveur : dans cette architecture, le serveur interprète le code PHP des pages web demandées et génère du code (HTML, XHTML, CSS par exemple) et des données (JPEG, GIF, PNG par exemple) pouvant être interprétés et rendus par un navigateur web. PHP peut également générer d'autres formats comme le WML, le SVG et le PDF.

    1. In the functions.php of your WordPress theme add:

      Same solution but in PHP

      php function hints() { header("link: </wp-content/themes/phpied2/style.css>; rel=preload, </wp-includes/css/dist/block-library/style.min.css?ver=5.4.1>; rel=preload"); } add_action('send_headers', 'hints');

  7. Jun 2022
    1. <?php$base = array("orange", "banana", "apple", "raspberry");$replacements = array(0 => "pineapple", 4 => "cherry");$replacements2 = array(0 => "grape");$basket = array_replace($base, $replacements, $replacements2);print_r($basket);?> The above example will output: Array ( [0] => grape [1] => banana [2] => apple [3] => raspberry [4] => cherry )

      array_replace() replaces the values of array with values having the same keys in each of the following arrays.

  8. May 2022
    1. FastCGI是语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程一直保持在内存,不是fork-and-execute,并因此获得较高的性能。FastCGI支持分布式部署,可以部署在WEB服务器以外的多个主机上。 PHP-CGI作为PHP自带的PHP FastCGI管理器对FastCGI的管理方式简单,也不够灵活高效。 PHP-FPM为了解决PHP-CGI的不足,为PHP FastCGI提供了一种新的进程管理方式,可以有效控制进程,平滑重载PHP配置,其master process是常驻内存的,worker process有static、dynamic、ondemand三种管理方式。PHP-FPM进程池中的CGI在接受并处理完pm.max_requests个用户请求后将会respawn,并不会保证单个CGI是long-live and always be running,而会以更加灵活高效的方式来保证客户端的连接请求可以被多个CGI处理。
    1. 首先,跨域请求分为两种,一种是简单请求,即get请求和post请求(不带多余的请求头),这种情况下,浏览器会直接请求,在有允许跨域的头的情况下,予以显示。(这里并不是说没有跨域头服务器就不返回数据了,数据是照常返回的,但是浏览器拦截了返回数据。)另一种呢是复杂请求,即非get或post请求,或者是有了自定义头的请求。这种情况下,浏览器会首先发送一个options请求(预请求),来确是否允许跨域。在服务器返回的跨域条件都允许之后,浏览器才会发送正式请求。

      首先,跨域请求分为两种,一种是简单请求,即get请求和post请求(不带多余的请求头),这种情况下,浏览器会直接请求,在有允许跨域的头的情况下,予以显示。(这里并不是说没有跨域头服务器就不返回数据了,数据是照常返回的,但是浏览器拦截了返回数据。) 另一种呢是复杂请求,即非get或post请求,或者是有了自定义头的请求。这种情况下,浏览器会首先发送一个options请求(预请求),来确是否允许跨域。在服务器返回的跨域条件都允许之后,浏览器才会发送正式请求。

    2. php 跨域请求执行了两次接口, CORS,

      php,请求跨域接口;执行了两次请求;OPTIONS(预处理);get(真正请求);

      按理来说,OPTIONS(预处理) 只是判断 header('Access-Control-Allow-Headers:x-requested-with,content-type');是否通过;通过了,才执行get; 现在出现的问题是,OPTIONS请求也执行了一次程序;然后get也执行了一次程序;

      解决办法: if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') { exit; }

    1. {错误:spawn C:\ wamp \ bin \ php \ php7.2.14 ENOENT 在Process.ChildProcess._handle.onexit at on OnErrorNT(internal / child_process.js:406:16) at process._tickCallback(internal / process / next_tick.js:63: 19) errno:'ENOENT', 代码:'ENOENT', 系统调用:'spawn C:\ wamp \ bin \ php \ php7.2.14', 路径:'C:\ \ wamp \ bin \ php \ php7.2.14', spawnargs:['c:\ wamp \ www \ NULB \ admin \ index.php']} < / pre>

  9. Apr 2022
  10. Jan 2022
  11. Dec 2021
  12. Feb 2021
  13. May 2020
    1. Programming languages These will probably expose my ignorance pretty nicely.

      When to use different programming languages (advice from an Amazon employee):

      • Java - enterprise applications
      • C# - Microsoft's spin on Java (useful in the Microsoft's ecosystem)
      • Ruby - when speed is more important then legibility or debugging
      • Python - same as Ruby but also for ML/AI (don't forget to use type hinting to make life a little saner)
      • Go/Rust - fresh web service where latency and performance were more important than community/library support
      • Haskell/Erlang - for very elegant/mathematical functional approach without a lot of business logic
      • Clojure - in situation when you love Lisp (?)
      • Kotlin/Scala - languages compiling to JVM bytecode (preferable over Clojure). Kotlin works with Java and has great IntelliJ support
      • C - classes of applications (operating systems, language design, low-level programming and hardware)
      • C++ - robotics, video games and high frequency trading where the performance gains from no garbage collection make it preferable to Java
      • PHP/Hack - testing server changes without rebuilding. PHP is banned at Amazon due to security reasons, but its successor, Hack, runs a lot of Facebook and Slack's backends
  14. Apr 2020
  15. Mar 2020
    1. And so was born PHP, it feels like a natural extension to HTML itself. You write your code between your HTML file itself and then be able to run those parts on the server, which further generate HTML and the final HTML gets send to the browser.This was extremely powerful. We could serve completely different pages to different users even though all of them access the same URL like Facebook. We could use a database on a server and store some data there, then based on some conditions use this data to modify the generated HTML and technically have an infinite number of pages available to serve (e-commerce).

      Birth of PHP - way to serve different content under the same URL

    1. The popular question in my company these days is “Rails or WordPress?”, but I will probably touch upon the broader questions of “MVC or CMS?” and “Ruby or PHP?”, so you can often substitute “Rails” for “MVC framework” in the article.
  16. Jan 2020
    1. REST exposes Uniform Resource Identifiers (URI) that are linked to resources. These links are called REST endpoints. Depending on the HTTP type used to access them, they will perform an action on the resource (change its state). The HTTP type is used to signal the REST verb to be performed.

      How REST works in a nutshell

  17. Dec 2019
  18. Nov 2019
  19. Oct 2019
    1. This can become messy when you have a lot of configurations in your Entity. Another issue is that your annotations are coupled to your source code. Your database implementations details, or any other configurations are coupled to your domain object. This goes against the guidelines of clean code. Your domain object (Entity) should only have one reason to change.

      Thank you for saying that loud.

  20. Aug 2019
    1. Centric web solution is the renowned best web development company.

      We have a very highly experienced and expert development team who are experts in web design & development.

      We provide various services like Wordpress web development, eCommerce web development, Wordpress theme design and plugin development, website maintenance & optimization.

      For more our services call us on +91 98587 58541 or visit our website https://www.centricwebsolution.com/.

      Our Services Are:-

      • Web Design & Development
      • WordPress Development
      • WooCommerce Development
      • Custom Web Application Development
      • Website Migration Services
      • Website Maintenance & Performance optimization
      • Website Plugin and API Development
      • Website Store Optimization
      • PHP Web Development
      • Enterprise Web Application Development
      • Laravel Development Services
      • Angularjs Development Services

  21. Aug 2016
    1. Back when PHP had less than 100 functions and the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the various function name lengths names were picked specifically to make them fit into a specific length bucket.

      ...

  22. Nov 2014
    1. There’s a certain amount of snobbery about PHP, but I’ve no truck for such snark. PHP is the Web’s BASIC. It’s everywhere, beginner-friendly, and I like it.