recentpopularlog in

kme : samplecode   284

« earlier  
Python Example
But... what's the deal with this web site?

Update: Ryan made it -
python  samplecode 
june 2019 by kme
Simple Gtk3 Webkit Example (Vala) |
Simple Gtk3 Webkit Example (Vala). GitHub Gist: instantly share code, notes, and snippets.
webkitgtk  webkit  vala  devel  samplecode 
may 2019 by kme
shamil/indicator-places: Very simple app-indicator, which shows gtk-bookmarks (aka places) |
Doesn't work with elementaryOS Freya, due to their changing the indicator API, I guess.
Very simple app-indicator, which shows gtk-bookmarks (aka places) - shamil/indicator-places
python  appindicator  gtkbookmarks  bookmarks  placesmenu  samplecode 
may 2019 by kme
riseuplabs / crabgrass · GitLab |
Crabgrass is a web application designed for activist groups to be better able to collaborate online. Mostly, it is a glorified wiki with fine-grain control over access rights.
ruby  rails  wiki  collaboration  activism  webapp  samplecode  webdevel 
february 2019 by kme
xpath - Why doesn't xmlstarlet select all nodes? - Stack Overflow |
Is this what you need?
<code class="language-bash">xml sel -t -m "//@category" -v "." -o " " books.xml</code>

or to separate the results on each line
<code class="language-bash">xml sel -t -m "//@category" -v "." -n books.xml</code>
xml  xpath  xmlstarlet  webdevel  samplecode  patternmatching 
march 2018 by kme
Basic Relationship Patterns — SQLAlchemy 0.9 Documentation |
The bidirectional version adds backrefs to both relationships:
<code class="language-python">
class Association(Base):
__tablename__ = 'association'
left_id = Column(Integer, ForeignKey(''), primary_key=True)
right_id = Column(Integer, ForeignKey(''), primary_key=True)
extra_data = Column(String(50))
child = relationship("Child", backref="parent_assocs")

class Parent(Base):
__tablename__ = 'left'
id = Column(Integer, primary_key=True)
children = relationship("Association", backref="parent")

class Child(Base):
__tablename__ = 'right'
id = Column(Integer, primary_key=True)

Working with the association pattern in its direct form requires that child objects are associated with an association instance before being appended to the parent; similarly, access from parent to child goes through the association object:
<code class="language-python"># create parent, append a child via association
p = Parent()
a = Association(extra_data="some data")
a.child = Child()

# iterate through child objects via association, including association
# attributes
for assoc in p.children:
print assoc.extra_data
print assoc.child</code>
sqlalchemy  dba  webdevel  flask-admin  samplecode  maybesolution 
february 2018 by kme
Toolbar ▲ Prism plugins |
<code class="language-javascript">
function setUpToolbar() {
// there's a bug in the example at
// (you need to pass 'env' to the second argument of registerButton)
Prism.plugins.toolbar.registerButton('select-code', function(env) {
var button = document.createElement('button');
button.innerHTML = 'Select Code';

button.addEventListener('click', function() {
// Source:
if (document.body.createTextRange) { // ms
var range = document.body.createTextRange();
} else if (window.getSelection) { // moz, opera, webkit
var selection = window.getSelection();
var range = document.createRange();

return button;
prismjs  javascript  library  syntaxhighlighting  webdevel  samplecode  bug  solution 
october 2017 by kme
xml - How to execute XPath one-liners from shell? - Stack Overflow -
What on earth do all these options do?
<code class="language-bash">xmlstarlet sel -T -t -m '//element/@attribute' -v '.' -n filename.xml</code>
Nokogiri. If I write this wrapper I could call the wrapper in the way described above:

<code class="language-ruby">

require 'nokogiri'

Nokogiri::XML(STDIN).xpath(ARGV[0]).each do |row|
puts row
XML::XPath. Would work with this wrapper:


use strict;
use warnings;
use XML::XPath;

my $root = XML::XPath->new(ioref => 'STDIN');
for my $node ($root->find($ARGV[0])->get_nodelist) {
print($node->getData, "\n");

<code class="language-bash">
xmllint --xpath '//element/@attribute' file.xml
xmlstarlet sel -t -v "//element/@attribute" file.xml
saxon-lint --xpath '//element/@attribute' file.xml

In Python with lxml:
So to do the same for normal Web content—HTML docs that aren’t necessarily well-formed XML:
<code class="language-bash">
echo "<p>foo<div>bar</div><p>baz" | python -c "from sys import stdin; \
from lxml import html; \
print '\n'.join(html.tostring(node) for node in html.parse(stdin).xpath('//p'))"

And to instead use html5lib (to ensure you get the same parsing behavior as Web browsers—because like browser parsers, html5lib conforms to the parsing requirements in the HTML spec).
<code class="language-bash">
echo "<p>foo<div>bar</div><p>baz" | python -c "from sys import stdin; \
import html5lib; from lxml import html; \
doc = html5lib.parse(stdin, treebuilder='lxml', namespaceHTMLElements=False); \
print '\n'.join(html.tostring(node) for node in doc.xpath('//p'))
xpath  xml  xslt  parsing  ruby  textprocessing  webdevel  commandline  cli  oneliner  list  recommendation  samplecode 
october 2017 by kme
« earlier      
per page:    204080120160

Copy this bookmark:

to read