Posts by intersex (202)


My name is Jasper Camber Holton. I write, code, make music, and I am the developer of Uglek.com. π

This user is an administrator.

Has 202 posts, follows 14 users and is followed by 8 users.

Last seen at October 17, 2021 14:19

Premium Member
@intersexs profile photo

Highlight Your Code With a Django Regex Template Filter This is a Django template filter that uses python regex to highlight code. It works by using regular expressions to get all occurrences of code beginning with *(language)* followed by ***, in this example, (python) for the language. It then takes the code from these and including the language and formats it for an embed using PrismJS.com. The comments explain what each line of code does. In the below example, the *\** is escaped with a \ to prevent it from messing up the template filter. One drawback of this is it does mean you can't use three stars (*) anywhere on a post with embedding (that's why I have it escaped).

@register.filter(name='embedcode') # Register the filter
def embedcode(value):
    sections = value.split("*\**") # Split by sections of code followed by delimiter
    rvalue = "" # Init return value
    for index, section in enumerate(sections): # Enumerate over the code blocks
        if index < len(sections)-1: # Add delimiter except for last block
            section = section + "*\**"
        scripts = re.findall(r"(\*\((\w+)\)\*([\d\D]+)\*\*\*)", section) # Three groups, a main group for the entire text, sub groups for language and code.
        dic = {} # Empty dictionary for find and replace
        for script in scripts: # Iterate through the scripts, get the language and code
            language = script[1]
            code = script[2]
            if language != 'language':
                dic[script[0]] = '(html tags) pre>code class=\"language-' + language + '\">' + code + '/code>/pre>' # Add the embed code to the dictionary with the main group, language and code
        for i, j in dic.items(): # Find and replace
            section = section.replace(i, j)
        rvalue = rvalue + section
    return rvalue
Below is a photo of the regex in action.

View the photo from a post by @intersex

@intersexs profile photo

I added code embeds so now I can show off code directly on the site. I'm not supporting every language to start with, but a lot of languages are already supported. To add code, use *(language)* before the code you want to embed, and *** after the code. For example,

Here is some code below.
// Reload the suggested posts div with more posts
function reloadSuggested(){
    $.ajax({
    url : "/suggested/",
    success : function(result){ 
    document.getElementById("suggested").innerHTML = result;
        $('#reloadsuggested').on('click', reloadSuggested);
      }
    });
}
$('#reloadsuggested').on('click', reloadSuggested);


@intersexs profile photo

I forgot to post when I added it, but you can make rainbow elements in Uglek posts by adding class="rainbow" to any tag. The below is a paragraph (p) tag with a rainbow class.

Here's an example. This is some rainbow text. This is some more rainbow text so you can truly see the rainbow effect. It works better with more text.


@intersexs profile photo

The Malaria Vaccine Will Drastically Improve Lives Across the World Malaria is a dangerous disease spread by mosquitoes. It has been treatable with medication for decades, but only recently has a vaccine been made available for the disease. This vaccine is going to change lives drastically in Africa, Asia, and across the world. It's great news for anyone who has ever caught malaria, and especially those at risk. A vaccine could help reduce the spread and therefore the risk of malaria, which devastates many communities. The vaccine is already being made available to people, and it is effective. The vaccine could prevent as many as four out of every ten cases of malaria, and three out of every ten severe cases. How does the vaccine work? Malaria is a parasite that destroys cells in order to reproduce, spreading through the "spit" of mosquitoes, infecting the person. This vaccine specifically targets Plasmodium falciparum, the most deadly and common parasite in many parts of Africa and Asia. This vaccine partially blocks the parasites' access into human cells and therefore prevents disease. It is effective at four doses, given a month apart at five, six, and seven months old, and a final booster around 18 months. Children are at the most risk for malaria, so it is logical to vaccinate them first. Unlike adults, they have not had a chance to build up immunity. The company making the vaccine, GSK, hasn't released information about how much the vaccine will cost. Largely vaccination campaigns rely on international support and support from donors. The company's pilot programs in Ghana, Kenya, and Malawi are in progress, and the company says it has donated 10 million doses for the study. A quarter of those doses have been used. GSK is committed to providing 15 million doses a year. More doses could be made available by 2022 or early 2023. Researchers estimate that 100 million doses may be needed every year by the end of the decade. The vaccine will be given along with other routine immunizations. It is a real step forward in the battle against malaria and other infectious diseases.

View the photo from a post by @intersex

@intersexs profile photo

This is a photo from the way back from Valhalla Lake. The colors are awesome around this time of year, we were lucky to have a beautiful blue sky.

View the photo from a post by @intersex

@intersexs profile photo

On the way to Valhalla Lake, another photo from the hike This is the hillside in fall colors.

View the photo from a post by @intersex

@intersexs profile photo

Looking down over Valhalla Lake, Washington This photo was taken from a vista above the lake. We hiked up to the highest point to see the awesome views.

View the photo from a post by @intersex

@intersex, likes this,

@intersexs profile photo

Valhalla Lake, Washington This is an awesome lake with a beautiful reflection and pretty fall colors this time of year.

View the photo from a post by @intersex

@intersexs profile photo

AI Coding Technology Doesn't Pose a Threat to Human Workers A new coding technology, Codex, writes code with AI to tackle programming challenges that would otherwise be difficult for humans to solve. However, according to Tom Smith, who oversees an A.I. startup called Gado Images, the technology doesn't pose a threat to professional coders. In fact, he sees it as a tool that could "make a coder's life a lot easier". Built by OpenAI, one of the most ambitious artificial intelligence research labs, Codex sheds light on the current state of artificial intelligence. Huge leaps and bounds have been made, though most AI systems complement human workers instead of replacing them. With the consistent rise of technology called neural networks, machines can now learn skills by looking at large amounts of data. By statistically computing and analyzing cat photos, a neural network can recognize a cat. This is the same technology that recognizes your voice, translates between languages, and drives self-driving cars. Years ago, researchers at similar labs to OpenAI built neural networks that analyzed large amounts of text, including digital books, articles, and other text on the internet. After computing patterns in the text, the networks were able to predict the next word in the sentence. With some short seed text, the AIs could produce full paragraphs by completing the thought. GPT-3, created by OpenAI, could write Twitter posts, speeches, poetry, and news for example. Surprisingly, the program could even write its own computer code, though the programs were short and simple. The AI had learned from code on the internet. OpenAI took the project a step further, and created Codex, training a new system on an enormous database of prose and code. The resulting system understands both prose and code and cooperates with user input. If you tell it to do something, it will do something. Codex can generate programs in 12 languages and translate between them. But it only writes the right code 37% of the time. It makes mistakes, and it can't reason like a human. It doesn't really think on its own. From a beta testers' perspective, the code that Codex produces is impressive. But it needs some tweaking to work correctly. That means that codex is only useful to an experienced programmer. Using the technology, GitHub, a popular online service for computer programmers, now offers a tool called Copilot that suggests the next line of code, like how autocomplete tools suggest the next word when texting or emailing. It's a way of writing code without writing a lot of code, at least with GitHubs product. It's not always perfect, but it is close enough. Codex could help novices learn to code, and professionals code faster. With his start-up, Gado Images, Mr. Smith set out to sort through photo archives of newspapers and libraries, captioning and tagging the photos before sharing them. But technology could only do part of the job. Its output still needed to be manually reviewed and edited before it worked. And a seasoned archivist still needed to find the best and most important photos. These tools don't completely remove the need for humans. They can be helpful at making our jobs easier though. AI isn't taking all the jobs, instead, it's making all of them easier.

View the photo from a post by @intersex

@intersexs profile photo

Less Sugar in Packaged Foods Could Prevent Heart Disease According to a new health and economic model, it's imperative that manufacturers of packaged food products reduce the sugar added to their products. Reducing added sugar by 20% from foods and 40% from drinks could prevent 2.48 million strokes, heart attacks, cardiac arrests, and other cardiovascular disease problems. The study, published in Circulation, also concludes that 490,000 cardiovascular deaths and 750,000 diabetes cases in the U.S. could be prevented by reducing sugar content in products. The researchers, from the Massachusetts General Hospital, the Friedman School of Nutrition Science and Policy at Tufts University, Harvard T.H. Chan School of Public Health, and New York City Department of Health and Mental Hygiene created a model to simulate the impacts of policy proposed by an organization called NSSRI, an initiative aimed at reducing the sugar content of sugary products. NSSRI, the U.S. National Salt and Sugar Reduction Initiative, finalized the policy this February. Their goal is to get sugar giants in the industry to reformulate their products. However, implementing a national policy would require government support to monitor and regulate companies as they work toward the targets of sugar reduction. The researchers hope to build a consensus and "push the reformulation initiative forward in the next few years," according to Siyi Shangguan, MD, MPH. show that it would be healthier and better to put less sugar in products. The U.S. could expect to save $4.28 million in healthcare costs, and $118.04 billion over the lifetime of the current population ages 25 to 79, according to the researchers' model. Even more money could be saved with the societal costs of lost productivity from Americans developing diseases from excessive sugar consumption averted. The policy would become cost-effective at six years and cost-saving at nine years. Previous product reformation efforts have been successful in reducing other harmful nutrients such as trans fat and sodium. However, the U.S. lags behind other countries in sugar-formulation efforts, while the UK, Norway, and Singapore are taking the lead on sugar-reformulation efforts. Consumption of sugary packaged foods and beverages is strongly linked to obesity, type 2 diabetes, and cardiovascular disease, the leading cause of mortality in the U.S. Another scientist participating in the study, Dariush Mozaffarian, MD, DrPH, says that sugar is one of the "most obvious additives" in the food supply which should be reduced to reasonable amounts. The findings suggest that it is "time to implement a national program" in order to meet sugar reduction targets, which can generate major improvements in the health of the population.

View the photo from a post by @intersex


© Uglek, 2021

Terms of Use and Privacy Policy