Skip to content

Instantly share code, notes, and snippets.

View peterschmiz's full-sized avatar

Péter Schmíz peterschmiz

View GitHub Profile
@peterschmiz
peterschmiz / claude_3.5_sonnet_artifacts.xml
Created March 13, 2025 11:46 — forked from dedlim/claude_3.5_sonnet_artifacts.xml
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@peterschmiz
peterschmiz / scrollbar-measurement.js
Created September 24, 2017 08:43
Javascript based scrollbar measurement
const measureScrollbar = () => {
const scrollDiv = document.createElement('div');
let scrollbarWidth = 0;
scrollDiv.classList.add('scrollbar-measure');
document.body.appendChild(scrollDiv);
scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
@peterschmiz
peterschmiz / import.js
Created September 21, 2017 14:49
Import differences in ES6
import { forEach } from 'lodash';
// vs.
import forEach from 'lodash/forEach';
// First import bundles the whole lodash library while
// the second import only the core and the forEach!
// Big difference in the final file size!
@peterschmiz
peterschmiz / debug-grid.css
Last active September 21, 2017 10:17
Visual responsive grid helper with pseudo element
@import '../base/_sizes.pcss';
@import '../base/_color.pcss';
body.debug {
&::after {
position: fixed;
content: '';
width: auto;
max-width: 100%;
@peterschmiz
peterschmiz / responsive-type.pcss
Created September 19, 2017 14:26
Responsive type example (with responsive type PostCSS plugin)
// https://github.com/seaneking/postcss-responsive-type
h3 {
margin-bottom: calc(28px + 34 * ((100vw - 375px) / 1650));
font-size: responsive 18px 26px;
font-range: 375px 2025px;
text-transform: uppercase;
line-height: responsive 22px 28px;
line-height-range: 375px 2025px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function solution(A) {
var p, idx,
leftSum = 0,
rightSum = 0,
totalSum = A.reduce(function(pv, cv) { return pv + cv; }, 0),
lastMin,
currentMin,
N = A.length;
if (N === 2) {
function solution(A) {
var missing_int = 0,
i = 0;
for (i; i < A.length; i++) {
missing_int ^= A[i];
}
return missing_int;
function solution(A, K) {
var result = [],
i = 0,
j = 0;
if (A.length === 0) {
return A;
}
if (K > A.length) {
function solution(N) {
return parseInt(N, 10).
toString(2).
replace(/^0+|0+$/g, '').
split('1').
reduce(function (a, b) {
return a.length > b.length ? a : b;
}).length
}